diff --git a/cef_paths2.gypi b/cef_paths2.gypi index d4f23d9f6..e12b6173c 100644 --- a/cef_paths2.gypi +++ b/cef_paths2.gypi @@ -107,6 +107,7 @@ 'tests/cefclient/res/domaccess.html', 'tests/cefclient/res/localstorage.html', 'tests/cefclient/res/logo.png', + 'tests/cefclient/res/other_tests.html', 'tests/cefclient/res/performance.html', 'tests/cefclient/res/xmlhttprequest.html', 'tests/cefclient/resource_util.h', @@ -138,6 +139,7 @@ 'tests/cefclient/cefclient_mac.mm', 'tests/cefclient/client_handler_mac.mm', 'tests/cefclient/resource_util_mac.mm', + 'tests/cefclient/resource_util_posix.cpp', 'tests/cefclient/window_test_mac.mm', ], 'cefclient_sources_mac_helper': [ @@ -164,6 +166,7 @@ 'tests/cefclient/process_helper_mac.cpp', 'tests/cefclient/resource_util.h', 'tests/cefclient/resource_util_mac.mm', + 'tests/cefclient/resource_util_posix.cpp', 'tests/cefclient/scheme_test.cpp', 'tests/cefclient/scheme_test.h', 'tests/cefclient/string_util.cpp', @@ -183,6 +186,7 @@ 'tests/cefclient/res/domaccess.html', 'tests/cefclient/res/localstorage.html', 'tests/cefclient/res/logo.png', + 'tests/cefclient/res/other_tests.html', 'tests/cefclient/res/performance.html', 'tests/cefclient/res/window.html', 'tests/cefclient/res/xmlhttprequest.html', @@ -191,6 +195,7 @@ 'tests/cefclient/cefclient_gtk.cpp', 'tests/cefclient/client_handler_gtk.cpp', 'tests/cefclient/resource_util_linux.cpp', + 'tests/cefclient/resource_util_posix.cpp', 'tests/cefclient/window_test_gtk.cpp', ], 'cefclient_bundle_resources_linux': [ @@ -199,6 +204,7 @@ 'tests/cefclient/res/domaccess.html', 'tests/cefclient/res/localstorage.html', 'tests/cefclient/res/logo.png', + 'tests/cefclient/res/other_tests.html', 'tests/cefclient/res/performance.html', 'tests/cefclient/res/window.html', 'tests/cefclient/res/xmlhttprequest.html', diff --git a/tests/cefclient/cefclient.cpp b/tests/cefclient/cefclient.cpp index 030b21f8d..3ea1a5a9c 100644 --- a/tests/cefclient/cefclient.cpp +++ b/tests/cefclient/cefclient.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// Copyright (c) 2013 The Chromium Embedded Framework Authors. All rights // reserved. Use of this source code is governed by a BSD-style license that // can be found in the LICENSE file. @@ -174,42 +174,6 @@ void RunPluginInfoTest(CefRefPtr browser) { CefVisitWebPluginInfo(new Visitor(browser)); } -void RunLocalStorageTest(CefRefPtr browser) { - browser->GetMainFrame()->LoadURL("http://tests/localstorage"); -} - -void RunAccelerated2DCanvasTest(CefRefPtr browser) { - browser->GetMainFrame()->LoadURL( - "http://mudcu.be/labs/JS1k/BreathingGalaxies.html"); -} - -void RunAcceleratedLayersTest(CefRefPtr browser) { - browser->GetMainFrame()->LoadURL( - "http://webkit.org/blog-files/3d-transforms/poster-circle.html"); -} - -void RunWebGLTest(CefRefPtr browser) { - browser->GetMainFrame()->LoadURL( - "http://webglsamples.googlecode.com/hg/field/field.html"); -} - -void RunHTML5VideoTest(CefRefPtr browser) { - browser->GetMainFrame()->LoadURL( - "http://www.youtube.com/watch?v=siOHh0uzcuY&html5=True"); -} - -void RunXMLHTTPRequestTest(CefRefPtr browser) { - browser->GetMainFrame()->LoadURL("http://tests/xmlhttprequest"); -} - -void RunDragDropTest(CefRefPtr browser) { - browser->GetMainFrame()->LoadURL("http://html5demos.com/drag"); -} - -void RunGeolocationTest(CefRefPtr browser) { - browser->GetMainFrame()->LoadURL("http://html5demos.com/geo"); -} - -void RunTransparencyTest(CefRefPtr browser) { - browser->GetMainFrame()->LoadURL("http://tests/transparency"); +void RunOtherTests(CefRefPtr browser) { + browser->GetMainFrame()->LoadURL("http://tests/other_tests"); } diff --git a/tests/cefclient/cefclient.h b/tests/cefclient/cefclient.h index 081926ede..d04046dd3 100644 --- a/tests/cefclient/cefclient.h +++ b/tests/cefclient/cefclient.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights +// Copyright (c) 2013 The Chromium Embedded Framework Authors. All rights // reserved. Use of this source code is governed by a BSD-style license that // can be found in the LICENSE file. @@ -45,15 +45,7 @@ void RunGetTextTest(CefRefPtr browser); void RunRequestTest(CefRefPtr browser); void RunPopupTest(CefRefPtr browser); void RunPluginInfoTest(CefRefPtr browser); -void RunLocalStorageTest(CefRefPtr browser); -void RunAccelerated2DCanvasTest(CefRefPtr browser); -void RunAcceleratedLayersTest(CefRefPtr browser); -void RunWebGLTest(CefRefPtr browser); -void RunHTML5VideoTest(CefRefPtr browser); -void RunXMLHTTPRequestTest(CefRefPtr browser); -void RunDragDropTest(CefRefPtr browser); -void RunGeolocationTest(CefRefPtr browser); -void RunTransparencyTest(CefRefPtr browser); +void RunOtherTests(CefRefPtr browser); #if defined(OS_WIN) void RunTransparentPopupTest(CefRefPtr browser); diff --git a/tests/cefclient/cefclient.rc b/tests/cefclient/cefclient.rc index 92b58e093..a75a2565e 100644 --- a/tests/cefclient/cefclient.rc +++ b/tests/cefclient/cefclient.rc @@ -34,6 +34,7 @@ IDS_DOMACCESS BINARY "res\\domaccess.html" IDS_LOCALSTORAGE BINARY "res\\localstorage.html" IDS_LOGO BINARY "res\\logo.png" IDS_LOGOBALL BINARY "res\\logoball.png" +IDS_OTHER_TESTS BINARY "res\\other_tests.html" IDS_PERFORMANCE BINARY "res\\performance.html" IDS_TRANSPARENCY BINARY "res\\transparency.html" IDS_WINDOW BINARY "res\\window.html" @@ -77,20 +78,12 @@ BEGIN MENUITEM "Window", ID_TESTS_WINDOW MENUITEM "Plugin Info", ID_TESTS_PLUGIN_INFO MENUITEM "DOM Access", ID_TESTS_DOM_ACCESS - MENUITEM "Local Storage", ID_TESTS_LOCALSTORAGE - MENUITEM "XMLHttpRequest", ID_TESTS_XMLHTTPREQUEST - MENUITEM "Accelerated 2D Canvas", ID_TESTS_ACCELERATED2DCANVAS - MENUITEM "Accelerated Layers", ID_TESTS_ACCELERATEDLAYERS - MENUITEM "WebGL", ID_TESTS_WEBGL - MENUITEM "HTML5 Video", ID_TESTS_HTML5VIDEO - MENUITEM "Drag && Drop", ID_TESTS_DRAGDROP - MENUITEM "Geolocation", ID_TESTS_GEOLOCATION - MENUITEM "Transparency", ID_TESTS_TRANSPARENCY MENUITEM "Zoom In", ID_TESTS_ZOOM_IN MENUITEM "Zoom Out", ID_TESTS_ZOOM_OUT MENUITEM "Zoom Reset", ID_TESTS_ZOOM_RESET - MENUITEM "Begin Tracing", ID_TESTS_BEGIN_TRACING - MENUITEM "End Tracing", ID_TESTS_END_TRACING + MENUITEM "Begin Tracing", ID_TESTS_TRACING_BEGIN + MENUITEM "End Tracing", ID_TESTS_TRACING_END + MENUITEM "Other Tests", ID_TESTS_OTHER_TESTS END END diff --git a/tests/cefclient/cefclient_gtk.cpp b/tests/cefclient/cefclient_gtk.cpp index c048bb863..82896480f 100644 --- a/tests/cefclient/cefclient_gtk.cpp +++ b/tests/cefclient/cefclient_gtk.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights +// Copyright (c) 2013 The Chromium Embedded Framework Authors. All rights // reserved. Use of this source code is governed by a BSD-style license that // can be found in the LICENSE file. @@ -52,7 +52,7 @@ void TerminationSignalHandler(int signatl) { AppQuitMessageLoop(); } -// Callback for Debug > Get Source... menu item. +// Callback for Tests > Get Source... menu item. gboolean GetSourceActivated(GtkWidget* widget) { if (g_handler.get() && g_handler->GetBrowserId()) RunGetSourceTest(g_handler->GetBrowser()); @@ -60,7 +60,7 @@ gboolean GetSourceActivated(GtkWidget* widget) { return FALSE; // Don't stop this message. } -// Callback for Debug > Get Text... menu item. +// Callback for Tests > Get Text... menu item. gboolean GetTextActivated(GtkWidget* widget) { if (g_handler.get() && g_handler->GetBrowserId()) RunGetTextTest(g_handler->GetBrowser()); @@ -68,87 +68,7 @@ gboolean GetTextActivated(GtkWidget* widget) { return FALSE; // Don't stop this message. } -// Callback for Debug > Request... menu item. -gboolean RequestActivated(GtkWidget* widget) { - if (g_handler.get() && g_handler->GetBrowserId()) - RunRequestTest(g_handler->GetBrowser()); - - return FALSE; // Don't stop this message. -} - -// Callback for Debug > Local Storage... menu item. -gboolean LocalStorageActivated(GtkWidget* widget) { - if (g_handler.get() && g_handler->GetBrowserId()) - RunLocalStorageTest(g_handler->GetBrowser()); - - return FALSE; // Don't stop this message. -} - -// Callback for Debug > XMLHttpRequest... menu item. -gboolean XMLHttpRequestActivated(GtkWidget* widget) { - if (g_handler.get() && g_handler->GetBrowserId()) - RunXMLHTTPRequestTest(g_handler->GetBrowser()); - - return FALSE; // Don't stop this message. -} - -// Callback for Debug > Scheme Handler... menu item. -gboolean SchemeHandlerActivated(GtkWidget* widget) { - if (g_handler.get() && g_handler->GetBrowserId()) - scheme_test::RunTest(g_handler->GetBrowser()); - - return FALSE; // Don't stop this message. -} - -// Callback for Debug > JavaScript Binding... menu item. -gboolean BindingActivated(GtkWidget* widget) { - if (g_handler.get() && g_handler->GetBrowserId()) - binding_test::RunTest(g_handler->GetBrowser()); - - return FALSE; // Don't stop this message. -} - -// Callback for Debug > Performance... menu item. -gboolean PerformanceActivated(GtkWidget* widget) { - if (g_handler.get() && g_handler->GetBrowserId()) - performance_test::RunTest(g_handler->GetBrowser()); - - return FALSE; // Don't stop this message. -} - -// Callback for Debug > Dialogs... menu item. -gboolean DialogsActivated(GtkWidget* widget) { - if (g_handler.get() && g_handler->GetBrowserId()) - dialog_test::RunTest(g_handler->GetBrowser()); - - return FALSE; // Don't stop this message. -} - -// Callback for Debug > Window... menu item. -gboolean WindowActivated(GtkWidget* widget) { - if (g_handler.get() && g_handler->GetBrowserId()) - window_test::RunTest(g_handler->GetBrowser()); - - return FALSE; // Don't stop this message. -} - -// Callback for Debug > Plugin Info... menu item. -gboolean PluginInfoActivated(GtkWidget* widget) { - if (g_handler.get() && g_handler->GetBrowserId()) - RunPluginInfoTest(g_handler->GetBrowser()); - - return FALSE; // Don't stop this message. -} - -// Callback for Debug > DOM Access... menu item. -gboolean DOMAccessActivated(GtkWidget* widget) { - if (g_handler.get() && g_handler->GetBrowserId()) - dom_test::RunTest(g_handler->GetBrowser()); - - return FALSE; // Don't stop this message. -} - -// Callback for Debug > Popup Window... menu item. +// Callback for Tests > Popup Window... menu item. gboolean PopupWindowActivated(GtkWidget* widget) { if (g_handler.get() && g_handler->GetBrowserId()) RunPopupTest(g_handler->GetBrowser()); @@ -156,48 +76,71 @@ gboolean PopupWindowActivated(GtkWidget* widget) { return FALSE; // Don't stop this message. } -// Callback for Debug > Accelerated 2D Canvas... menu item. -gboolean Accelerated2DCanvasActivated(GtkWidget* widget) { +// Callback for Tests > Request... menu item. +gboolean RequestActivated(GtkWidget* widget) { if (g_handler.get() && g_handler->GetBrowserId()) - RunAccelerated2DCanvasTest(g_handler->GetBrowser()); + RunRequestTest(g_handler->GetBrowser()); return FALSE; // Don't stop this message. } -// Callback for Debug > Accelerated Layers... menu item. -gboolean AcceleratedLayersActivated(GtkWidget* widget) { +// Callback for Tests > Scheme Handler... menu item. +gboolean SchemeHandlerActivated(GtkWidget* widget) { if (g_handler.get() && g_handler->GetBrowserId()) - RunAcceleratedLayersTest(g_handler->GetBrowser()); + scheme_test::RunTest(g_handler->GetBrowser()); return FALSE; // Don't stop this message. } -// Callback for Debug > WebGL... menu item. -gboolean WebGLActivated(GtkWidget* widget) { +// Callback for Tests > JavaScript Binding... menu item. +gboolean BindingActivated(GtkWidget* widget) { if (g_handler.get() && g_handler->GetBrowserId()) - RunWebGLTest(g_handler->GetBrowser()); + binding_test::RunTest(g_handler->GetBrowser()); return FALSE; // Don't stop this message. } -// Callback for Debug > HTML5 Video... menu item. -gboolean HTML5VideoActivated(GtkWidget* widget) { +// Callback for Tests > Performance... menu item. +gboolean PerformanceActivated(GtkWidget* widget) { if (g_handler.get() && g_handler->GetBrowserId()) - RunHTML5VideoTest(g_handler->GetBrowser()); + performance_test::RunTest(g_handler->GetBrowser()); return FALSE; // Don't stop this message. } -// Callback for Debug > HTML5 Drag & Drop... menu item. -gboolean HTML5DragDropActivated(GtkWidget* widget) { +// Callback for Tests > Dialogs... menu item. +gboolean DialogsActivated(GtkWidget* widget) { if (g_handler.get() && g_handler->GetBrowserId()) - RunDragDropTest(g_handler->GetBrowser()); + dialog_test::RunTest(g_handler->GetBrowser()); return FALSE; // Don't stop this message. } +// Callback for Tests > Window... menu item. +gboolean WindowActivated(GtkWidget* widget) { + if (g_handler.get() && g_handler->GetBrowserId()) + window_test::RunTest(g_handler->GetBrowser()); -// Callback for Debug > Zoom In... menu item. + return FALSE; // Don't stop this message. +} + +// Callback for Tests > Plugin Info... menu item. +gboolean PluginInfoActivated(GtkWidget* widget) { + if (g_handler.get() && g_handler->GetBrowserId()) + RunPluginInfoTest(g_handler->GetBrowser()); + + return FALSE; // Don't stop this message. +} + +// Callback for Tests > DOM Access... menu item. +gboolean DOMAccessActivated(GtkWidget* widget) { + if (g_handler.get() && g_handler->GetBrowserId()) + dom_test::RunTest(g_handler->GetBrowser()); + + return FALSE; // Don't stop this message. +} + +// Callback for Tests > Zoom In... menu item. gboolean ZoomInActivated(GtkWidget* widget) { if (g_handler.get() && g_handler->GetBrowserId()) { CefRefPtr browser = g_handler->GetBrowser(); @@ -207,7 +150,7 @@ gboolean ZoomInActivated(GtkWidget* widget) { return FALSE; // Don't stop this message. } -// Callback for Debug > Zoom Out... menu item. +// Callback for Tests > Zoom Out... menu item. gboolean ZoomOutActivated(GtkWidget* widget) { if (g_handler.get() && g_handler->GetBrowserId()) { CefRefPtr browser = g_handler->GetBrowser(); @@ -217,7 +160,7 @@ gboolean ZoomOutActivated(GtkWidget* widget) { return FALSE; // Don't stop this message. } -// Callback for Debug > Zoom Reset... menu item. +// Callback for Tests > Zoom Reset... menu item. gboolean ZoomResetActivated(GtkWidget* widget) { if (g_handler.get() && g_handler->GetBrowserId()) { CefRefPtr browser = g_handler->GetBrowser(); @@ -227,7 +170,7 @@ gboolean ZoomResetActivated(GtkWidget* widget) { return FALSE; // Don't stop this message. } -// Callback for Debug > Begin Tracing menu item. +// Callback for Tests > Begin Tracing menu item. gboolean BeginTracingActivated(GtkWidget* widget) { if (g_handler.get()) g_handler->BeginTracing(); @@ -235,7 +178,7 @@ gboolean BeginTracingActivated(GtkWidget* widget) { return FALSE; // Don't stop this message. } -// Callback for Debug > End Tracing menu item. +// Callback for Tests > End Tracing menu item. gboolean EndTracingActivated(GtkWidget* widget) { if (g_handler.get()) g_handler->EndTracing(); @@ -243,6 +186,14 @@ gboolean EndTracingActivated(GtkWidget* widget) { return FALSE; // Don't stop this message. } +// Callback for Tests > Other Tests... menu item. +gboolean OtherTestsActivated(GtkWidget* widget) { + if (g_handler.get() && g_handler->GetBrowserId()) + RunOtherTests(g_handler->GetBrowser()); + + return FALSE; // Don't stop this message. +} + // Callback for when you click the back button. void BackButtonClicked(GtkButton* button) { if (g_handler.get() && g_handler->GetBrowserId()) @@ -302,12 +253,10 @@ GtkWidget* CreateMenuBar() { G_CALLBACK(GetSourceActivated)); AddMenuEntry(debug_menu, "Get Text", G_CALLBACK(GetTextActivated)); + AddMenuEntry(debug_menu, "Popup Window", + G_CALLBACK(PopupWindowActivated)); AddMenuEntry(debug_menu, "Request", G_CALLBACK(RequestActivated)); - AddMenuEntry(debug_menu, "Local Storage", - G_CALLBACK(LocalStorageActivated)); - AddMenuEntry(debug_menu, "XMLHttpRequest", - G_CALLBACK(XMLHttpRequestActivated)); AddMenuEntry(debug_menu, "Scheme Handler", G_CALLBACK(SchemeHandlerActivated)); AddMenuEntry(debug_menu, "JavaScript Binding", @@ -322,18 +271,6 @@ GtkWidget* CreateMenuBar() { G_CALLBACK(PluginInfoActivated)); AddMenuEntry(debug_menu, "DOM Access", G_CALLBACK(DOMAccessActivated)); - AddMenuEntry(debug_menu, "Popup Window", - G_CALLBACK(PopupWindowActivated)); - AddMenuEntry(debug_menu, "Accelerated 2D Canvas", - G_CALLBACK(Accelerated2DCanvasActivated)); - AddMenuEntry(debug_menu, "Accelerated Layers", - G_CALLBACK(AcceleratedLayersActivated)); - AddMenuEntry(debug_menu, "WebGL", - G_CALLBACK(WebGLActivated)); - AddMenuEntry(debug_menu, "HTML5 Video", - G_CALLBACK(HTML5VideoActivated)); - AddMenuEntry(debug_menu, "HTML5 Drag & Drop", - G_CALLBACK(HTML5DragDropActivated)); AddMenuEntry(debug_menu, "Zoom In", G_CALLBACK(ZoomInActivated)); AddMenuEntry(debug_menu, "Zoom Out", @@ -344,6 +281,8 @@ GtkWidget* CreateMenuBar() { G_CALLBACK(BeginTracingActivated)); AddMenuEntry(debug_menu, "End Tracing", G_CALLBACK(EndTracingActivated)); + AddMenuEntry(debug_menu, "Other Tests", + G_CALLBACK(OtherTestsActivated)); return menu_bar; } diff --git a/tests/cefclient/cefclient_mac.mm b/tests/cefclient/cefclient_mac.mm index 8e6e3077d..b582733be 100644 --- a/tests/cefclient/cefclient_mac.mm +++ b/tests/cefclient/cefclient_mac.mm @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. +// Copyright (c) 2013 The Chromium Embedded Framework Authors. // Portions copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -206,9 +206,8 @@ NSButton* MakeButton(NSRect* rect, NSString* title, NSView* parent) { - (void)createApp:(id)object; - (IBAction)testGetSource:(id)sender; - (IBAction)testGetText:(id)sender; +- (IBAction)testPopupWindow:(id)sender; - (IBAction)testRequest:(id)sender; -- (IBAction)testLocalStorage:(id)sender; -- (IBAction)testXMLHttpRequest:(id)sender; - (IBAction)testSchemeHandler:(id)sender; - (IBAction)testBinding:(id)sender; - (IBAction)testPerformance:(id)sender; @@ -216,17 +215,12 @@ NSButton* MakeButton(NSRect* rect, NSString* title, NSView* parent) { - (IBAction)testWindow:(id)sender; - (IBAction)testPluginInfo:(id)sender; - (IBAction)testDOMAccess:(id)sender; -- (IBAction)testPopupWindow:(id)sender; -- (IBAction)testAccelerated2DCanvas:(id)sender; -- (IBAction)testAcceleratedLayers:(id)sender; -- (IBAction)testWebGL:(id)sender; -- (IBAction)testHTML5Video:(id)sender; -- (IBAction)testDragDrop:(id)sender; - (IBAction)testZoomIn:(id)sender; - (IBAction)testZoomOut:(id)sender; - (IBAction)testZoomReset:(id)sender; - (IBAction)testBeginTracing:(id)sender; - (IBAction)testEndTracing:(id)sender; +- (IBAction)testOtherTests:(id)sender; @end @implementation ClientAppDelegate @@ -278,27 +272,6 @@ NSButton* MakeButton(NSRect* rect, NSString* title, NSView* parent) { [testMenu addItemWithTitle:@"DOM Access" action:@selector(testDOMAccess:) keyEquivalent:@""]; - [testMenu addItemWithTitle:@"Local Storage" - action:@selector(testLocalStorage:) - keyEquivalent:@""]; - [testMenu addItemWithTitle:@"XMLHttpRequest" - action:@selector(testXMLHttpRequest:) - keyEquivalent:@""]; - [testMenu addItemWithTitle:@"Accelerated 2D Canvas" - action:@selector(testAccelerated2DCanvas:) - keyEquivalent:@""]; - [testMenu addItemWithTitle:@"Accelerated Layers" - action:@selector(testAcceleratedLayers:) - keyEquivalent:@""]; - [testMenu addItemWithTitle:@"WebGL" - action:@selector(testWebGL:) - keyEquivalent:@""]; - [testMenu addItemWithTitle:@"HTML5 Video" - action:@selector(testHTML5Video:) - keyEquivalent:@""]; - [testMenu addItemWithTitle:@"Drag & Drop" - action:@selector(testDragDrop:) - keyEquivalent:@""]; [testMenu addItemWithTitle:@"Zoom In" action:@selector(testZoomIn:) keyEquivalent:@""]; @@ -314,6 +287,9 @@ NSButton* MakeButton(NSRect* rect, NSString* title, NSView* parent) { [testMenu addItemWithTitle:@"End Tracing" action:@selector(testEndTracing:) keyEquivalent:@""]; + [testMenu addItemWithTitle:@"Other Tests" + action:@selector(testOtherTests:) + keyEquivalent:@""]; [testItem setSubmenu:testMenu]; [menubar addItem:testItem]; @@ -412,21 +388,16 @@ NSButton* MakeButton(NSRect* rect, NSString* title, NSView* parent) { RunGetTextTest(g_handler->GetBrowser()); } +- (IBAction)testPopupWindow:(id)sender { + if (g_handler.get() && g_handler->GetBrowserId()) + RunPopupTest(g_handler->GetBrowser()); +} + - (IBAction)testRequest:(id)sender { if (g_handler.get() && g_handler->GetBrowserId()) RunRequestTest(g_handler->GetBrowser()); } -- (IBAction)testLocalStorage:(id)sender { - if (g_handler.get() && g_handler->GetBrowserId()) - RunLocalStorageTest(g_handler->GetBrowser()); -} - -- (IBAction)testXMLHttpRequest:(id)sender { - if (g_handler.get() && g_handler->GetBrowserId()) - RunXMLHTTPRequestTest(g_handler->GetBrowser()); -} - - (IBAction)testSchemeHandler:(id)sender { if (g_handler.get() && g_handler->GetBrowserId()) scheme_test::RunTest(g_handler->GetBrowser()); @@ -462,36 +433,6 @@ NSButton* MakeButton(NSRect* rect, NSString* title, NSView* parent) { dom_test::RunTest(g_handler->GetBrowser()); } -- (IBAction)testPopupWindow:(id)sender { - if (g_handler.get() && g_handler->GetBrowserId()) - RunPopupTest(g_handler->GetBrowser()); -} - -- (IBAction)testAccelerated2DCanvas:(id)sender { - if (g_handler.get() && g_handler->GetBrowserId()) - RunAccelerated2DCanvasTest(g_handler->GetBrowser()); -} - -- (IBAction)testAcceleratedLayers:(id)sender { - if (g_handler.get() && g_handler->GetBrowserId()) - RunAcceleratedLayersTest(g_handler->GetBrowser()); -} - -- (IBAction)testWebGL:(id)sender { - if (g_handler.get() && g_handler->GetBrowserId()) - RunWebGLTest(g_handler->GetBrowser()); -} - -- (IBAction)testHTML5Video:(id)sender { - if (g_handler.get() && g_handler->GetBrowserId()) - RunHTML5VideoTest(g_handler->GetBrowser()); -} - -- (IBAction)testDragDrop:(id)sender { - if (g_handler.get() && g_handler->GetBrowserId()) - RunDragDropTest(g_handler->GetBrowser()); -} - - (IBAction)testZoomIn:(id)sender { if (g_handler.get() && g_handler->GetBrowserId()) { CefRefPtr browser = g_handler->GetBrowser(); @@ -523,6 +464,11 @@ NSButton* MakeButton(NSRect* rect, NSString* title, NSView* parent) { g_handler->EndTracing(); } +- (IBAction)testOtherTests:(id)sender { + if (g_handler.get() && g_handler->GetBrowserId()) + RunOtherTests(g_handler->GetBrowser()); +} + // Sent by the default notification center immediately before the application // terminates. Quitting CEF is handled in ClientHandler::OnBeforeClose(). - (void)applicationWillTerminate:(NSNotification *)aNotification { diff --git a/tests/cefclient/cefclient_win.cpp b/tests/cefclient/cefclient_win.cpp index f36fc5818..283530b19 100644 --- a/tests/cefclient/cefclient_win.cpp +++ b/tests/cefclient/cefclient_win.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// Copyright (c) 2013 The Chromium Embedded Framework Authors. All rights // reserved. Use of this source code is governed by a BSD-style license that // can be found in the LICENSE file. @@ -446,42 +446,6 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, if (browser.get()) dom_test::RunTest(browser); return 0; - case ID_TESTS_LOCALSTORAGE: // Test localStorage - if (browser.get()) - RunLocalStorageTest(browser); - return 0; - case ID_TESTS_ACCELERATED2DCANVAS: // Test accelerated 2d canvas - if (browser.get()) - RunAccelerated2DCanvasTest(browser); - return 0; - case ID_TESTS_ACCELERATEDLAYERS: // Test accelerated layers - if (browser.get()) - RunAcceleratedLayersTest(browser); - return 0; - case ID_TESTS_WEBGL: // Test WebGL - if (browser.get()) - RunWebGLTest(browser); - return 0; - case ID_TESTS_HTML5VIDEO: // Test HTML5 video - if (browser.get()) - RunHTML5VideoTest(browser); - return 0; - case ID_TESTS_XMLHTTPREQUEST: // Test XMLHttpRequest - if (browser.get()) - RunXMLHTTPRequestTest(browser); - return 0; - case ID_TESTS_DRAGDROP: // Test drag & drop - if (browser.get()) - RunDragDropTest(browser); - return 0; - case ID_TESTS_GEOLOCATION: // Test geolocation - if (browser.get()) - RunGeolocationTest(browser); - return 0; - case ID_TESTS_TRANSPARENCY: // Test transparency - if (browser.get()) - RunTransparencyTest(browser); - return 0; case ID_TESTS_ZOOM_IN: if (browser.get()) ModifyZoom(browser, 0.5); @@ -494,12 +458,16 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, if (browser.get()) browser->GetHost()->SetZoomLevel(0.0); return 0; - case ID_TESTS_BEGIN_TRACING: + case ID_TESTS_TRACING_BEGIN: g_handler->BeginTracing(); return 0; - case ID_TESTS_END_TRACING: + case ID_TESTS_TRACING_END: g_handler->EndTracing(); return 0; + case ID_TESTS_OTHER_TESTS: + if (browser.get()) + RunOtherTests(browser); + return 0; } break; } diff --git a/tests/cefclient/client_handler.cpp b/tests/cefclient/client_handler.cpp index 706dc094c..ab950ab1b 100644 --- a/tests/cefclient/client_handler.cpp +++ b/tests/cefclient/client_handler.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights +// Copyright (c) 2013 The Chromium Embedded Framework Authors. All rights // reserved. Use of this source code is governed by a BSD-style license that // can be found in the LICENSE file. @@ -13,6 +13,7 @@ #include "include/cef_process_util.h" #include "include/cef_runnable.h" #include "include/cef_trace.h" +#include "include/cef_url.h" #include "include/wrapper/cef_stream_resource_handler.h" #include "cefclient/binding_test.h" #include "cefclient/cefclient.h" @@ -25,6 +26,7 @@ #include "cefclient/string_util.h" #include "cefclient/window_test.h" +namespace { // Custom menu command Ids. enum client_menu_ids { @@ -36,6 +38,51 @@ enum client_menu_ids { CLIENT_ID_TESTMENU_RADIOITEM3, }; +const char kTestOrigin[] = "http://tests/"; + +// Retrieve the file name and mime type based on the specified url. +bool ParseTestUrl(const std::string& url, + std::string* file_name, + std::string* mime_type) { + // Retrieve the path component. + CefURLParts parts; + CefParseURL(url, parts); + std::string file = CefString(&parts.path); + if (file.size() < 2) + return false; + + // Remove the leading slash. + file = file.substr(1); + + // Verify that the file name is valid. + for(size_t i = 0; i < file.size(); ++i) { + const char c = file[i]; + if (!isalpha(c) && !isdigit(c) && c != '_' && c != '.') + return false; + } + + // Determine the mime type based on the file extension, if any. + size_t pos = file.rfind("."); + if (pos != std::string::npos) { + std::string ext = file.substr(pos + 1); + if (ext == "html") + *mime_type = "text/html"; + else if (ext == "png") + *mime_type = "image/png"; + else + return false; + } else { + // Default to an html extension if none is specified. + *mime_type = "text/html"; + file += ".html"; + } + + *file_name = file; + return true; +} + +} // namespace + int ClientHandler::m_BrowserCount = 0; ClientHandler::ClientHandler() @@ -382,46 +429,28 @@ CefRefPtr ClientHandler::GetResourceHandler( CefRefPtr frame, CefRefPtr request) { std::string url = request->GetURL(); - if (url == "http://tests/request") { - // Show the request contents - std::string dump; - DumpRequestContents(request, dump); - CefRefPtr stream = - CefStreamReader::CreateForData( - static_cast(const_cast(dump.c_str())), - dump.size()); - ASSERT(stream.get()); - return new CefStreamResourceHandler("text/plain", stream); - } else if (url == "http://tests/dialogs") { - // Show the dialogs contents - CefRefPtr stream = - GetBinaryResourceReader("dialogs.html"); - ASSERT(stream.get()); - return new CefStreamResourceHandler("text/html", stream); - } else if (url == dom_test::kTestUrl) { - // Show the domaccess contents - CefRefPtr stream = - GetBinaryResourceReader("domaccess.html"); - ASSERT(stream.get()); - return new CefStreamResourceHandler("text/html", stream); - } else if (url == "http://tests/localstorage") { - // Show the localstorage contents - CefRefPtr stream = - GetBinaryResourceReader("localstorage.html"); - ASSERT(stream.get()); - return new CefStreamResourceHandler("text/html", stream); - } else if (url == "http://tests/transparency") { - // Show the transparency contents - CefRefPtr stream = - GetBinaryResourceReader("transparency.html"); - ASSERT(stream.get()); - return new CefStreamResourceHandler("text/html", stream); - } else if (url == "http://tests/xmlhttprequest") { - // Show the xmlhttprequest contents - CefRefPtr stream = - GetBinaryResourceReader("xmlhttprequest.html"); - ASSERT(stream.get()); - return new CefStreamResourceHandler("text/html", stream); + if (url.find(kTestOrigin) == 0) { + // Handle URLs in the test origin. + std::string file_name, mime_type; + if (ParseTestUrl(url, &file_name, &mime_type)) { + if (file_name == "request.html") { + // Show the request contents. + std::string dump; + DumpRequestContents(request, dump); + CefRefPtr stream = + CefStreamReader::CreateForData( + static_cast(const_cast(dump.c_str())), + dump.size()); + ASSERT(stream.get()); + return new CefStreamResourceHandler("text/plain", stream); + } else { + // Load the resource from file. + CefRefPtr stream = + GetBinaryResourceReader(file_name.c_str()); + if (stream.get()) + return new CefStreamResourceHandler(mime_type, stream); + } + } } CefRefPtr handler; diff --git a/tests/cefclient/res/other_tests.html b/tests/cefclient/res/other_tests.html new file mode 100644 index 000000000..a3892fcd7 --- /dev/null +++ b/tests/cefclient/res/other_tests.html @@ -0,0 +1,21 @@ + + +Other Tests + + +

Various other internal and external tests.

+ + + diff --git a/tests/cefclient/resource.h b/tests/cefclient/resource.h index 00d042d33..9e32c5976 100644 --- a/tests/cefclient/resource.h +++ b/tests/cefclient/resource.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// Copyright (c) 2013 The Chromium Embedded Framework Authors. All rights // reserved. Use of this source code is governed by a BSD-style license that // can be found in the LICENSE file. @@ -26,31 +26,23 @@ #define ID_WARN_DOWNLOADCOMPLETE 32001 #define ID_WARN_DOWNLOADERROR 32002 #define ID_QUIT 32500 -#define ID_TESTS_GETSOURCE 32760 -#define ID_TESTS_GETTEXT 32761 -#define ID_TESTS_POPUP 32762 -#define ID_TESTS_REQUEST 32763 -#define ID_TESTS_SCHEME_HANDLER 32764 -#define ID_TESTS_LOCALSTORAGE 32765 -#define ID_TESTS_ACCELERATED2DCANVAS 32766 -#define ID_TESTS_ACCELERATEDLAYERS 32767 -#define ID_TESTS_WEBGL 32768 -#define ID_TESTS_HTML5VIDEO 32769 -#define ID_TESTS_XMLHTTPREQUEST 32770 -#define ID_TESTS_DRAGDROP 32771 -#define ID_TESTS_GEOLOCATION 32772 -#define ID_TESTS_BINDING 32773 -#define ID_TESTS_DIALOGS 32774 -#define ID_TESTS_PLUGIN_INFO 32775 -#define ID_TESTS_DOM_ACCESS 32776 -#define ID_TESTS_ZOOM_IN 32777 -#define ID_TESTS_ZOOM_OUT 32778 -#define ID_TESTS_ZOOM_RESET 32779 -#define ID_TESTS_BEGIN_TRACING 32780 -#define ID_TESTS_END_TRACING 32781 -#define ID_TESTS_PERFORMANCE 32782 -#define ID_TESTS_TRANSPARENCY 32783 -#define ID_TESTS_WINDOW 32784 +#define ID_TESTS_BINDING 32700 +#define ID_TESTS_DIALOGS 32701 +#define ID_TESTS_DOM_ACCESS 32702 +#define ID_TESTS_GETSOURCE 32703 +#define ID_TESTS_GETTEXT 32704 +#define ID_TESTS_OTHER_TESTS 32705 +#define ID_TESTS_PERFORMANCE 32706 +#define ID_TESTS_PLUGIN_INFO 32707 +#define ID_TESTS_POPUP 32708 +#define ID_TESTS_REQUEST 32709 +#define ID_TESTS_SCHEME_HANDLER 32710 +#define ID_TESTS_TRACING_BEGIN 32711 +#define ID_TESTS_TRACING_END 32712 +#define ID_TESTS_WINDOW 32713 +#define ID_TESTS_ZOOM_IN 32714 +#define ID_TESTS_ZOOM_OUT 32715 +#define ID_TESTS_ZOOM_RESET 32716 #define IDC_STATIC -1 #define IDS_BINDING 1000 #define IDS_DIALOGS 1001 @@ -58,10 +50,11 @@ #define IDS_LOCALSTORAGE 1003 #define IDS_LOGO 1004 #define IDS_LOGOBALL 1005 -#define IDS_PERFORMANCE 1006 -#define IDS_TRANSPARENCY 1007 -#define IDS_WINDOW 1008 -#define IDS_XMLHTTPREQUEST 1009 +#define IDS_OTHER_TESTS 1006 +#define IDS_PERFORMANCE 1007 +#define IDS_TRANSPARENCY 1008 +#define IDS_WINDOW 1009 +#define IDS_XMLHTTPREQUEST 1010 // Avoid files associated with MacOS #define _X86_ diff --git a/tests/cefclient/resource_util.h b/tests/cefclient/resource_util.h index c382196f4..d38830792 100644 --- a/tests/cefclient/resource_util.h +++ b/tests/cefclient/resource_util.h @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights +// Copyright (c) 2013 The Chromium Embedded Framework Authors. All rights // reserved. Use of this source code is governed by a BSD-style license that // can be found in the LICENSE file. @@ -6,27 +6,18 @@ #define CEF_TESTS_CEFCLIENT_RESOURCE_UTIL_H_ #pragma once -#include "include/cef_base.h" - -class CefStreamReader; - -#if defined(OS_WIN) - -#include "cefclient/resource.h" - -// Load a resource of type BINARY -bool LoadBinaryResource(int binaryId, DWORD &dwSize, LPBYTE &pBytes); -CefRefPtr GetBinaryResourceReader(int binaryId); - -#elif defined(OS_MACOSX) || defined(OS_POSIX) - -#include // NOLINT(build/include_order) - -// Load the resource with the specified name. -bool LoadBinaryResource(const char* resource_name, std::string& resource_data); +#include +#include "include/cef_stream.h" +#if defined(OS_POSIX) +// Returns the directory containing resource files. +bool GetResourceDir(std::string& dir); #endif +// Retrieve a resource as a string. +bool LoadBinaryResource(const char* resource_name, std::string& resource_data); + +// Retrieve a resource as a steam reader. CefRefPtr GetBinaryResourceReader(const char* resource_name); #endif // CEF_TESTS_CEFCLIENT_RESOURCE_UTIL_H_ diff --git a/tests/cefclient/resource_util_linux.cpp b/tests/cefclient/resource_util_linux.cpp index 66b46267d..aa4f4a939 100644 --- a/tests/cefclient/resource_util_linux.cpp +++ b/tests/cefclient/resource_util_linux.cpp @@ -1,13 +1,11 @@ -// Copyright (c) 2011 The Chromium Embedded Framework Authors. +// Copyright (c) 2013 The Chromium Embedded Framework Authors. // Portions copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "cefclient/resource_util.h" #include -#include -#include "include/cef_stream.h" -#include "cefclient/util.h" +#include bool GetResourceDir(std::string& dir) { char buff[1024]; @@ -29,39 +27,3 @@ bool GetResourceDir(std::string& dir) { dir = std::string(buff); return true; } - -bool LoadBinaryResource(const char* resource_name, std::string& resource_data) { - std::string path; - if (!GetResourceDir(path)) - return false; - - path.append("/"); - path.append(resource_name); - - FILE* f = fopen(path.c_str(), "rb"); - if (!f) - return false; - - size_t bytes_read; - char buff[1024*8]; - - do { - bytes_read = fread(buff, 1, sizeof(buff)-1, f); - if (bytes_read > 0) - resource_data.append(buff, bytes_read); - } while (bytes_read > 0); - - fclose(f); - return true; -} - -CefRefPtr GetBinaryResourceReader(const char* resource_name) { - std::string path; - if (!GetResourceDir(path)) - return NULL; - - path.append("/"); - path.append(resource_name); - - return CefStreamReader::CreateForFile(path); -} diff --git a/tests/cefclient/resource_util_mac.mm b/tests/cefclient/resource_util_mac.mm index 98cfd8605..c4652a0cf 100644 --- a/tests/cefclient/resource_util_mac.mm +++ b/tests/cefclient/resource_util_mac.mm @@ -1,13 +1,12 @@ -// Copyright (c) 2011 The Chromium Embedded Framework Authors. +// Copyright (c) 2013 The Chromium Embedded Framework Authors. // Portions copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "cefclient/resource_util.h" #import #include #include -#include "cefclient/resource_util.h" -#include "include/cef_stream.h" #include "cefclient/util.h" namespace { @@ -15,14 +14,14 @@ namespace { bool AmIBundled() { // Implementation adapted from Chromium's base/mac/foundation_util.mm ProcessSerialNumber psn = {0, kCurrentProcess}; - + FSRef fsref; OSStatus pbErr; if ((pbErr = GetProcessBundleLocation(&psn, &fsref)) != noErr) { ASSERT(false); return false; } - + FSCatalogInfo info; OSErr fsErr; if ((fsErr = FSGetCatalogInfo(&fsref, kFSCatInfoNodeFlags, &info, @@ -34,9 +33,11 @@ bool AmIBundled() { return (info.nodeFlags & kFSNodeIsDirectoryMask); } +} // namespace + bool GetResourceDir(std::string& dir) { - // Implementation adapted from Chromium's base/base_path_mac.mm - if (AmIBundled()) { + // Implementation adapted from Chromium's base/base_path_mac.mm + if (AmIBundled()) { // Retrieve the executable directory. uint32_t pathSize = 0; _NSGetExecutablePath(NULL, &pathSize); @@ -56,42 +57,3 @@ bool GetResourceDir(std::string& dir) { return false; } } - -bool ReadFileToString(const char* path, std::string& data) { - // Implementation adapted from base/file_util.cc - FILE* file = fopen(path, "rb"); - if (!file) - return false; - - char buf[1 << 16]; - size_t len; - while ((len = fread(buf, 1, sizeof(buf), file)) > 0) - data.append(buf, len); - fclose(file); - - return true; -} - -} // namespace - -bool LoadBinaryResource(const char* resource_name, std::string& resource_data) { - std::string path; - if (!GetResourceDir(path)) - return false; - - path.append("/"); - path.append(resource_name); - - return ReadFileToString(path.c_str(), resource_data); -} - -CefRefPtr GetBinaryResourceReader(const char* resource_name) { - std::string path; - if (!GetResourceDir(path)) - return NULL; - - path.append("/"); - path.append(resource_name); - - return CefStreamReader::CreateForFile(path); -} diff --git a/tests/cefclient/resource_util_posix.cpp b/tests/cefclient/resource_util_posix.cpp new file mode 100644 index 000000000..68a4331f6 --- /dev/null +++ b/tests/cefclient/resource_util_posix.cpp @@ -0,0 +1,59 @@ +// Copyright (c) 2013 The Chromium Embedded Framework Authors. All rights +// reserved. Use of this source code is governed by a BSD-style license that +// can be found in the LICENSE file. + +#include "cefclient/resource_util.h" +#include + +namespace { + +bool FileExists(const char* path) { + FILE* f = fopen(path, "rb"); + if (f) { + fclose(f); + return true; + } + return false; +} + +bool ReadFileToString(const char* path, std::string& data) { + // Implementation adapted from base/file_util.cc + FILE* file = fopen(path, "rb"); + if (!file) + return false; + + char buf[1 << 16]; + size_t len; + while ((len = fread(buf, 1, sizeof(buf), file)) > 0) + data.append(buf, len); + fclose(file); + + return true; +} + +} // namespace + +bool LoadBinaryResource(const char* resource_name, std::string& resource_data) { + std::string path; + if (!GetResourceDir(path)) + return false; + + path.append("/"); + path.append(resource_name); + + return ReadFileToString(path.c_str(), resource_data); +} + +CefRefPtr GetBinaryResourceReader(const char* resource_name) { + std::string path; + if (!GetResourceDir(path)) + return NULL; + + path.append("/"); + path.append(resource_name); + + if (!FileExists(path.c_str())) + return NULL; + + return CefStreamReader::CreateForFile(path); +} diff --git a/tests/cefclient/resource_util_win.cpp b/tests/cefclient/resource_util_win.cpp index 135bac167..e14ab589d 100644 --- a/tests/cefclient/resource_util_win.cpp +++ b/tests/cefclient/resource_util_win.cpp @@ -1,16 +1,17 @@ -// Copyright (c) 2008-2009 The Chromium Embedded Framework Authors. All rights +// Copyright (c) 2013 The Chromium Embedded Framework Authors. All rights // reserved. Use of this source code is governed by a BSD-style license that // can be found in the LICENSE file. #include "cefclient/resource_util.h" #include "include/cef_stream.h" #include "include/wrapper/cef_byte_read_handler.h" +#include "cefclient/resource.h" #include "cefclient/util.h" -#if defined(OS_WIN) +namespace { bool LoadBinaryResource(int binaryId, DWORD &dwSize, LPBYTE &pBytes) { - extern HINSTANCE hInst; + HINSTANCE hInst = GetModuleHandle(NULL); HRSRC hRes = FindResource(hInst, MAKEINTRESOURCE(binaryId), MAKEINTRESOURCE(256)); if (hRes) { @@ -26,20 +27,7 @@ bool LoadBinaryResource(int binaryId, DWORD &dwSize, LPBYTE &pBytes) { return false; } -CefRefPtr GetBinaryResourceReader(int binaryId) { - DWORD dwSize; - LPBYTE pBytes; - - if (LoadBinaryResource(binaryId, dwSize, pBytes)) { - return CefStreamReader::CreateForHandler( - new CefByteReadHandler(pBytes, dwSize, NULL)); - } - - ASSERT(FALSE); // The resource should be found. - return NULL; -} - -CefRefPtr GetBinaryResourceReader(const char* resource_name) { +int GetResourceId(const char* resource_name) { // Map of resource labels to BINARY id values. static struct _resource_map { char* name; @@ -49,6 +37,9 @@ CefRefPtr GetBinaryResourceReader(const char* resource_name) { {"dialogs.html", IDS_DIALOGS}, {"domaccess.html", IDS_DOMACCESS}, {"localstorage.html", IDS_LOCALSTORAGE}, + {"logo.png", IDS_LOGO}, + {"logoball.png", IDS_LOGOBALL}, + {"other_tests.html", IDS_OTHER_TESTS}, {"performance.html", IDS_PERFORMANCE}, {"transparency.html", IDS_TRANSPARENCY}, {"window.html", IDS_WINDOW}, @@ -57,11 +48,44 @@ CefRefPtr GetBinaryResourceReader(const char* resource_name) { for (int i = 0; i < sizeof(resource_map)/sizeof(_resource_map); ++i) { if (!strcmp(resource_map[i].name, resource_name)) - return GetBinaryResourceReader(resource_map[i].id); + return resource_map[i].id; + } + + return 0; +} + +} // namespace + +bool LoadBinaryResource(const char* resource_name, std::string& resource_data) { + int resource_id = GetResourceId(resource_name); + if (resource_id == 0) + return false; + + DWORD dwSize; + LPBYTE pBytes; + + if (LoadBinaryResource(resource_id, dwSize, pBytes)) { + resource_data = std::string(reinterpret_cast(pBytes), dwSize); + return true; + } + + ASSERT(FALSE); // The resource should be found. + return false; +} + +CefRefPtr GetBinaryResourceReader(const char* resource_name) { + int resource_id = GetResourceId(resource_name); + if (resource_id == 0) + return NULL; + + DWORD dwSize; + LPBYTE pBytes; + + if (LoadBinaryResource(resource_id, dwSize, pBytes)) { + return CefStreamReader::CreateForHandler( + new CefByteReadHandler(pBytes, dwSize, NULL)); } ASSERT(FALSE); // The resource should be found. return NULL; } - -#endif // OS_WIN diff --git a/tests/cefclient/scheme_test.cpp b/tests/cefclient/scheme_test.cpp index ee33a4389..9a98b4282 100644 --- a/tests/cefclient/scheme_test.cpp +++ b/tests/cefclient/scheme_test.cpp @@ -65,24 +65,11 @@ class ClientSchemeHandler : public CefResourceHandler { mime_type_ = "text/html"; } else if (strstr(url.c_str(), "client.png") != NULL) { // Load the response image -#if defined(OS_WIN) - DWORD dwSize; - LPBYTE pBytes; - if (LoadBinaryResource(IDS_LOGO, dwSize, pBytes)) { - data_ = std::string(reinterpret_cast(pBytes), dwSize); - handled = true; - // Set the resulting mime type - mime_type_ = "image/jpg"; - } -#elif defined(OS_MACOSX) || defined(OS_LINUX) if (LoadBinaryResource("logo.png", data_)) { handled = true; // Set the resulting mime type mime_type_ = "image/png"; } -#else -#error "Unsupported platform" -#endif } if (handled) {