diff options
author | yoz <yoz@chromium.org> | 2014-09-09 16:16:32 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-09-09 23:27:26 +0000 |
commit | e8dc2f1ff837e32b9d02d65ab520d16187450bf9 (patch) | |
tree | b5c8ef60f013a1a38e8e3f3bf78a8bed3351b100 | |
parent | ea76f5f5c3d6e0f73876d040265ad121346e9f3d (diff) | |
download | chromium_src-e8dc2f1ff837e32b9d02d65ab520d16187450bf9.zip chromium_src-e8dc2f1ff837e32b9d02d65ab520d16187450bf9.tar.gz chromium_src-e8dc2f1ff837e32b9d02d65ab520d16187450bf9.tar.bz2 |
Use extensions::ResultCatcher; delete ExtensionApiTest::ResultCatcher.
BUG=388893
Review URL: https://codereview.chromium.org/555633003
Cr-Commit-Position: refs/heads/master@{#294031}
61 files changed, 196 insertions, 236 deletions
diff --git a/chrome/browser/DEPS b/chrome/browser/DEPS index ad12f48..74ce169 100644 --- a/chrome/browser/DEPS +++ b/chrome/browser/DEPS @@ -85,6 +85,7 @@ include_rules = [ "+extensions/browser", "+extensions/common", "+extensions/grit", + "+extensions/test", "+google/cacheinvalidation", # Sync invalidation API protobuf files. "+google_apis", "+google_update", diff --git a/chrome/browser/apps/app_browsertest.cc b/chrome/browser/apps/app_browsertest.cc index 5e5f320..1c837c2 100644 --- a/chrome/browser/apps/app_browsertest.cc +++ b/chrome/browser/apps/app_browsertest.cc @@ -44,6 +44,7 @@ #include "extensions/browser/notification_types.h" #include "extensions/browser/pref_names.h" #include "extensions/common/api/app_runtime.h" +#include "extensions/test/result_catcher.h" #include "net/test/embedded_test_server/embedded_test_server.h" #include "url/gurl.h" @@ -1089,7 +1090,7 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, #define MAYBE_Messaging Messaging #endif IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, MAYBE_Messaging) { - ExtensionApiTest::ResultCatcher result_catcher; + ResultCatcher result_catcher; LoadAndLaunchPlatformApp("messaging/app2", "Ready"); LoadAndLaunchPlatformApp("messaging/app1", "Launched"); EXPECT_TRUE(result_catcher.GetNextResult()); @@ -1309,7 +1310,7 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, ReinstallDataCleanup) { ASSERT_TRUE(extension); extension_id = extension->id(); - ExtensionApiTest::ResultCatcher result_catcher; + ResultCatcher result_catcher; EXPECT_TRUE(result_catcher.GetNextResult()); } @@ -1322,7 +1323,7 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, ReinstallDataCleanup) { ASSERT_TRUE(extension); ASSERT_EQ(extension_id, extension->id()); - ExtensionApiTest::ResultCatcher result_catcher; + ResultCatcher result_catcher; EXPECT_TRUE(result_catcher.GetNextResult()); } } diff --git a/chrome/browser/apps/app_pointer_lock_interactive_uitest.cc b/chrome/browser/apps/app_pointer_lock_interactive_uitest.cc index b514cc5..70ffefb 100644 --- a/chrome/browser/apps/app_pointer_lock_interactive_uitest.cc +++ b/chrome/browser/apps/app_pointer_lock_interactive_uitest.cc @@ -6,6 +6,7 @@ #include "chrome/browser/extensions/extension_test_message_listener.h" #include "chrome/browser/ui/extensions/application_launch.h" #include "chrome/test/base/interactive_test_utils.h" +#include "extensions/test/result_catcher.h" class ExtensionPointerLockTest : public extensions::PlatformAppBrowserTest { public: @@ -13,7 +14,7 @@ class ExtensionPointerLockTest : public extensions::PlatformAppBrowserTest { ExtensionTestMessageListener launched_listener("Launched", true); LoadAndLaunchPlatformApp(app_path, &launched_listener); - ResultCatcher catcher; + extensions::ResultCatcher catcher; if (!ui_test_utils::ShowAndFocusNativeWindow( GetFirstAppWindow()->GetNativeWindow())) { diff --git a/chrome/browser/apps/app_window_browsertest.cc b/chrome/browser/apps/app_window_browsertest.cc index 5651e4d..51945f1 100644 --- a/chrome/browser/apps/app_window_browsertest.cc +++ b/chrome/browser/apps/app_window_browsertest.cc @@ -12,8 +12,10 @@ #include "extensions/browser/app_window/app_window_geometry_cache.h" #include "extensions/common/constants.h" #include "extensions/common/extension.h" +#include "extensions/test/result_catcher.h" using extensions::AppWindowGeometryCache; +using extensions::ResultCatcher; // This helper class can be used to wait for changes in the app window // geometry cache registry for a specific window in a specific extension. diff --git a/chrome/browser/apps/app_window_interactive_uitest.cc b/chrome/browser/apps/app_window_interactive_uitest.cc index 38bfa33..3fbb0a2 100644 --- a/chrome/browser/apps/app_window_interactive_uitest.cc +++ b/chrome/browser/apps/app_window_interactive_uitest.cc @@ -6,6 +6,7 @@ #include "chrome/browser/extensions/extension_test_message_listener.h" #include "chrome/test/base/interactive_test_utils.h" #include "extensions/browser/app_window/native_app_window.h" +#include "extensions/test/result_catcher.h" #if defined(OS_MACOSX) && !defined(OS_IOS) #include "base/mac/mac_util.h" @@ -49,7 +50,7 @@ class AppWindowInteractiveTest : public extensions::PlatformAppBrowserTest { ExtensionTestMessageListener launched_listener("Launched", true); LoadAndLaunchPlatformApp("window_api_interactive", &launched_listener); - ResultCatcher catcher; + extensions::ResultCatcher catcher; launched_listener.Reply(testName); if (!catcher.GetNextResult()) { diff --git a/chrome/browser/apps/ephemeral_app_browsertest.cc b/chrome/browser/apps/ephemeral_app_browsertest.cc index 690f11b..41afd93 100644 --- a/chrome/browser/apps/ephemeral_app_browsertest.cc +++ b/chrome/browser/apps/ephemeral_app_browsertest.cc @@ -39,6 +39,7 @@ #include "extensions/browser/uninstall_reason.h" #include "extensions/common/extension.h" #include "extensions/common/switches.h" +#include "extensions/test/result_catcher.h" #include "sync/api/fake_sync_change_processor.h" #include "sync/api/sync_change_processor_wrapper_for_test.h" #include "sync/api/sync_error_factory_mock.h" @@ -54,6 +55,7 @@ using extensions::ExtensionRegistry; using extensions::ExtensionRegistryObserver; using extensions::ExtensionSystem; using extensions::Manifest; +using extensions::ResultCatcher; namespace { @@ -609,7 +611,7 @@ IN_PROC_BROWSER_TEST_F(EphemeralAppBrowserTest, ASSERT_TRUE(receiver); // Verify that messages are received while the app is running. - ExtensionApiTest::ResultCatcher result_catcher; + ResultCatcher result_catcher; LoadAndLaunchPlatformApp("ephemeral_apps/messaging_sender_success", "Launched"); EXPECT_TRUE(result_catcher.GetNextResult()); diff --git a/chrome/browser/chromeos/extensions/accessibility_features_apitest.cc b/chrome/browser/chromeos/extensions/accessibility_features_apitest.cc index 992dd32..8245a9e 100644 --- a/chrome/browser/chromeos/extensions/accessibility_features_apitest.cc +++ b/chrome/browser/chromeos/extensions/accessibility_features_apitest.cc @@ -11,6 +11,7 @@ #include "base/values.h" #include "chrome/browser/extensions/extension_apitest.h" #include "chrome/common/pref_names.h" +#include "extensions/test/result_catcher.h" // API tests for chrome.accessibilityFeatures API. // Note that the API is implemented using preference API infrastructure. diff --git a/chrome/browser/chromeos/extensions/file_manager/file_browser_handler_api_test.cc b/chrome/browser/chromeos/extensions/file_manager/file_browser_handler_api_test.cc index 56dc1a3..d4c313c 100644 --- a/chrome/browser/chromeos/extensions/file_manager/file_browser_handler_api_test.cc +++ b/chrome/browser/chromeos/extensions/file_manager/file_browser_handler_api_test.cc @@ -19,6 +19,7 @@ #include "chrome/test/base/ui_test_utils.h" #include "content/public/browser/browser_context.h" #include "extensions/common/extension.h" +#include "extensions/test/result_catcher.h" #include "webkit/browser/fileapi/external_mount_points.h" #include "webkit/common/fileapi/file_system_types.h" @@ -273,7 +274,7 @@ IN_PROC_BROWSER_TEST_F(FileBrowserHandlerExtensionTest, EndToEnd) { AddTmpMountPoint(extension->id()); - ResultCatcher catcher; + extensions::ResultCatcher catcher; GURL url = extension->GetResourceURL("test.html"); ui_test_utils::NavigateToURL(browser(), url); diff --git a/chrome/browser/chromeos/file_manager/external_filesystem_apitest.cc b/chrome/browser/chromeos/file_manager/external_filesystem_apitest.cc index 737d8c2..90e7d7e 100644 --- a/chrome/browser/chromeos/file_manager/external_filesystem_apitest.cc +++ b/chrome/browser/chromeos/file_manager/external_filesystem_apitest.cc @@ -24,6 +24,7 @@ #include "content/public/browser/notification_service.h" #include "content/public/test/test_utils.h" #include "extensions/browser/notification_types.h" +#include "extensions/test/result_catcher.h" #include "google_apis/drive/drive_api_parser.h" #include "google_apis/drive/test_util.h" #include "google_apis/drive/time_util.h" @@ -370,7 +371,7 @@ class FileSystemExtensionApiTestBase : public ExtensionApiTest { } } - ResultCatcher catcher; + extensions::ResultCatcher catcher; const Extension* file_browser = LoadExtensionAsComponentWithManifest( test_data_dir_.AppendASCII(filebrowser_path), diff --git a/chrome/browser/chromeos/login/kiosk_browsertest.cc b/chrome/browser/chromeos/login/kiosk_browsertest.cc index 079c5b6..b91772b 100644 --- a/chrome/browser/chromeos/login/kiosk_browsertest.cc +++ b/chrome/browser/chromeos/login/kiosk_browsertest.cc @@ -57,6 +57,7 @@ #include "extensions/browser/app_window/app_window_registry.h" #include "extensions/browser/app_window/native_app_window.h" #include "extensions/browser/extension_system.h" +#include "extensions/test/result_catcher.h" #include "google_apis/gaia/gaia_constants.h" #include "google_apis/gaia/gaia_switches.h" #include "google_apis/gaia/gaia_urls.h" @@ -1456,7 +1457,7 @@ IN_PROC_BROWSER_TEST_F(KioskUpdateTest, PRE_PreserveLocalData) { set_test_app_version("1.0.0"); set_test_crx_file(test_app_id() + ".crx"); - ResultCatcher catcher; + extensions::ResultCatcher catcher; StartAppLaunchFromLoginScreen(SimulateNetworkOnlineClosure()); WaitForAppLaunchSuccess(); ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); @@ -1468,7 +1469,7 @@ IN_PROC_BROWSER_TEST_F(KioskUpdateTest, PreserveLocalData) { set_test_app_id(kTestLocalFsKioskApp); set_test_app_version("2.0.0"); set_test_crx_file(test_app_id() + "_v2_read_and_verify_data.crx"); - ResultCatcher catcher; + extensions::ResultCatcher catcher; StartAppLaunchFromLoginScreen(SimulateNetworkOnlineClosure()); WaitForAppLaunchSuccess(); diff --git a/chrome/browser/chromeos/login/signin/oauth2_browsertest.cc b/chrome/browser/chromeos/login/signin/oauth2_browsertest.cc index ce9cb0e..ade4e56 100644 --- a/chrome/browser/chromeos/login/signin/oauth2_browsertest.cc +++ b/chrome/browser/chromeos/login/signin/oauth2_browsertest.cc @@ -34,6 +34,7 @@ #include "content/public/browser/notification_service.h" #include "content/public/test/browser_test_utils.h" #include "extensions/browser/process_manager.h" +#include "extensions/test/result_catcher.h" #include "google_apis/gaia/gaia_constants.h" #include "google_apis/gaia/gaia_urls.h" #include "net/cookies/canonical_cookie.h" @@ -745,7 +746,7 @@ IN_PROC_BROWSER_TEST_F(MergeSessionTest, XHRThrottle) { // Run background page tests. The tests will just wait for XHR request // to complete. - ResultCatcher catcher; + extensions::ResultCatcher catcher; scoped_ptr<ExtensionTestMessageListener> non_google_xhr_listener( new ExtensionTestMessageListener("non-google-xhr-received", false)); diff --git a/chrome/browser/extensions/active_tab_apitest.cc b/chrome/browser/extensions/active_tab_apitest.cc index 4fd0570..a27135a 100644 --- a/chrome/browser/extensions/active_tab_apitest.cc +++ b/chrome/browser/extensions/active_tab_apitest.cc @@ -8,6 +8,7 @@ #include "chrome/browser/ui/browser.h" #include "chrome/test/base/ui_test_utils.h" #include "extensions/common/extension.h" +#include "extensions/test/result_catcher.h" #include "net/test/embedded_test_server/embedded_test_server.h" namespace extensions { diff --git a/chrome/browser/extensions/api/context_menus/context_menu_apitest.cc b/chrome/browser/extensions/api/context_menus/context_menu_apitest.cc index b0afc15..e4cd9cf 100644 --- a/chrome/browser/extensions/api/context_menus/context_menu_apitest.cc +++ b/chrome/browser/extensions/api/context_menus/context_menu_apitest.cc @@ -8,6 +8,7 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser.h" #include "chrome/test/base/ui_test_utils.h" +#include "extensions/test/result_catcher.h" namespace extensions { diff --git a/chrome/browser/extensions/api/dial/dial_apitest.cc b/chrome/browser/extensions/api/dial/dial_apitest.cc index b86d59b..872b3ca 100644 --- a/chrome/browser/extensions/api/dial/dial_apitest.cc +++ b/chrome/browser/extensions/api/dial/dial_apitest.cc @@ -10,6 +10,7 @@ #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_test_message_listener.h" #include "extensions/common/switches.h" +#include "extensions/test/result_catcher.h" #include "testing/gmock/include/gmock/gmock.h" #include "url/gurl.h" @@ -52,7 +53,7 @@ IN_PROC_BROWSER_TEST_F(DialAPITest, MAYBE_DeviceListEvents) { ASSERT_TRUE(api.get()); extensions::DialRegistry::DeviceList devices; - ResultCatcher catcher; + extensions::ResultCatcher catcher; DialDeviceData device1; device1.set_device_id("1"); @@ -94,8 +95,8 @@ IN_PROC_BROWSER_TEST_F(DialAPITest, DiscoveryNoListeners) { // Make sure this API is only accessible to whitelisted extensions. IN_PROC_BROWSER_TEST_F(DialAPITest, NonWhitelistedExtension) { - ResultCatcher catcher; - catcher.RestrictToProfile(browser()->profile()); + extensions::ResultCatcher catcher; + catcher.RestrictToBrowserContext(browser()->profile()); ExtensionTestMessageListener listener("ready", true); const extensions::Extension* extension = LoadExtensionWithFlags( diff --git a/chrome/browser/extensions/api/extension_action/browser_action_apitest.cc b/chrome/browser/extensions/api/extension_action/browser_action_apitest.cc index eb6cc00..03a46bb 100644 --- a/chrome/browser/extensions/api/extension_action/browser_action_apitest.cc +++ b/chrome/browser/extensions/api/extension_action/browser_action_apitest.cc @@ -25,6 +25,7 @@ #include "extensions/browser/extension_system.h" #include "extensions/browser/notification_types.h" #include "extensions/common/feature_switch.h" +#include "extensions/test/result_catcher.h" #include "grit/theme_resources.h" #include "ui/base/resource/resource_bundle.h" #include "ui/gfx/image/image_skia.h" diff --git a/chrome/browser/extensions/api/extension_action/browser_action_interactive_test.cc b/chrome/browser/extensions/api/extension_action/browser_action_interactive_test.cc index d4f0cc5..1912380 100644 --- a/chrome/browser/extensions/api/extension_action/browser_action_interactive_test.cc +++ b/chrome/browser/extensions/api/extension_action/browser_action_interactive_test.cc @@ -24,6 +24,7 @@ #include "extensions/common/extension.h" #include "extensions/common/extension_set.h" #include "extensions/common/permissions/permissions_data.h" +#include "extensions/test/result_catcher.h" #if defined(OS_WIN) #include "ui/views/win/hwnd_util.h" diff --git a/chrome/browser/extensions/api/extension_action/page_action_apitest.cc b/chrome/browser/extensions/api/extension_action/page_action_apitest.cc index 3cefd0b..0a03fdb 100644 --- a/chrome/browser/extensions/api/extension_action/page_action_apitest.cc +++ b/chrome/browser/extensions/api/extension_action/page_action_apitest.cc @@ -21,6 +21,7 @@ #include "content/public/test/browser_test_utils.h" #include "extensions/browser/extension_system.h" #include "extensions/common/extension.h" +#include "extensions/test/result_catcher.h" using content::WebContents; diff --git a/chrome/browser/extensions/api/gcm/gcm_apitest.cc b/chrome/browser/extensions/api/gcm/gcm_apitest.cc index 46b02ff..0706b25 100644 --- a/chrome/browser/extensions/api/gcm/gcm_apitest.cc +++ b/chrome/browser/extensions/api/gcm/gcm_apitest.cc @@ -13,6 +13,9 @@ #include "chrome/common/chrome_switches.h" #include "chrome/common/pref_names.h" #include "chrome/test/base/ui_test_utils.h" +#include "extensions/test/result_catcher.h" + +using extensions::ResultCatcher; namespace { @@ -173,7 +176,7 @@ IN_PROC_BROWSER_TEST_F(GcmApiTest, SendMessageDefaultTTL) { IN_PROC_BROWSER_TEST_F(GcmApiTest, OnMessagesDeleted) { ResultCatcher catcher; - catcher.RestrictToProfile(profile()); + catcher.RestrictToBrowserContext(profile()); const extensions::Extension* extension = LoadTestExtension(kEventsExtension, "on_messages_deleted.html"); @@ -186,7 +189,7 @@ IN_PROC_BROWSER_TEST_F(GcmApiTest, OnMessagesDeleted) { IN_PROC_BROWSER_TEST_F(GcmApiTest, OnMessage) { ResultCatcher catcher; - catcher.RestrictToProfile(profile()); + catcher.RestrictToBrowserContext(profile()); const extensions::Extension* extension = LoadTestExtension(kEventsExtension, "on_message.html"); @@ -209,7 +212,7 @@ IN_PROC_BROWSER_TEST_F(GcmApiTest, OnMessage) { IN_PROC_BROWSER_TEST_F(GcmApiTest, OnSendError) { ResultCatcher catcher; - catcher.RestrictToProfile(profile()); + catcher.RestrictToBrowserContext(profile()); const extensions::Extension* extension = LoadTestExtension(kEventsExtension, "on_send_error.html"); @@ -248,9 +251,10 @@ IN_PROC_BROWSER_TEST_F(GcmApiTest, OnSendError) { IN_PROC_BROWSER_TEST_F(GcmApiTest, Incognito) { ResultCatcher catcher; - catcher.RestrictToProfile(profile()); + catcher.RestrictToBrowserContext(profile()); ResultCatcher incognito_catcher; - incognito_catcher.RestrictToProfile(profile()->GetOffTheRecordProfile()); + incognito_catcher.RestrictToBrowserContext( + profile()->GetOffTheRecordProfile()); ASSERT_TRUE(RunExtensionTestIncognito("gcm/functions/incognito")); diff --git a/chrome/browser/extensions/api/i18n/i18n_apitest.cc b/chrome/browser/extensions/api/i18n/i18n_apitest.cc index 8d7cde3..96c3605 100644 --- a/chrome/browser/extensions/api/i18n/i18n_apitest.cc +++ b/chrome/browser/extensions/api/i18n/i18n_apitest.cc @@ -10,6 +10,7 @@ #include "chrome/browser/ui/browser.h" #include "chrome/test/base/ui_test_utils.h" #include "extensions/common/extension.h" +#include "extensions/test/result_catcher.h" #include "net/test/embedded_test_server/embedded_test_server.h" IN_PROC_BROWSER_TEST_F(ExtensionApiTest, I18N) { @@ -38,7 +39,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, I18NUpdate) { const extensions::Extension* extension = LoadExtension(extension_dir.path()); - ResultCatcher catcher; + extensions::ResultCatcher catcher; // Test that the messages.json file is loaded and the i18n message is loaded. ui_test_utils::NavigateToURL( diff --git a/chrome/browser/extensions/api/mdns/mdns_apitest.cc b/chrome/browser/extensions/api/mdns/mdns_apitest.cc index 411d3ce..4be0607 100644 --- a/chrome/browser/extensions/api/mdns/mdns_apitest.cc +++ b/chrome/browser/extensions/api/mdns/mdns_apitest.cc @@ -8,6 +8,7 @@ #include "chrome/browser/extensions/extension_service.h" #include "chrome/common/extensions/api/mdns.h" #include "extensions/common/switches.h" +#include "extensions/test/result_catcher.h" #include "testing/gmock/include/gmock/gmock.h" using extensions::DnsSdRegistry; @@ -85,7 +86,7 @@ IN_PROC_BROWSER_TEST_F(MDnsAPITest, MAYBE_RegisterListener) { EXPECT_TRUE(RunExtensionSubtest("mdns/api", "register_listener.html")) << message_; - ResultCatcher catcher; + extensions::ResultCatcher catcher; // Dispatch 3 events, one of which should not be sent to the test extension. DnsSdRegistry::DnsSdServiceList services; @@ -128,7 +129,7 @@ IN_PROC_BROWSER_TEST_F(MDnsAPITest, MAYBE_RegisterMultipleListeners) { "register_multiple_listeners.html")) << message_; - ResultCatcher catcher; + extensions::ResultCatcher catcher; DnsSdRegistry::DnsSdServiceList services; extensions::DnsSdService service; diff --git a/chrome/browser/extensions/api/media_galleries/media_galleries_apitest.cc b/chrome/browser/extensions/api/media_galleries/media_galleries_apitest.cc index e091747..7fae535 100644 --- a/chrome/browser/extensions/api/media_galleries/media_galleries_apitest.cc +++ b/chrome/browser/extensions/api/media_galleries/media_galleries_apitest.cc @@ -28,6 +28,7 @@ #include "content/public/test/test_utils.h" #include "extensions/browser/extension_system.h" #include "extensions/common/extension.h" +#include "extensions/test/result_catcher.h" #include "media/base/test_data_util.h" #if defined(OS_WIN) || defined(OS_MACOSX) @@ -468,7 +469,7 @@ IN_PROC_BROWSER_TEST_F(MediaGalleriesPlatformAppPpapiTest, SendFilesystem) { const extensions::Extension* extension = LoadExtension(app_dir()); ASSERT_TRUE(extension); - ResultCatcher catcher; + extensions::ResultCatcher catcher; AppLaunchParams params(browser()->profile(), extension, extensions::LAUNCH_CONTAINER_NONE, diff --git a/chrome/browser/extensions/api/notifications/notifications_apitest.cc b/chrome/browser/extensions/api/notifications/notifications_apitest.cc index 8cfa4a2..e6d1c06 100644 --- a/chrome/browser/extensions/api/notifications/notifications_apitest.cc +++ b/chrome/browser/extensions/api/notifications/notifications_apitest.cc @@ -16,11 +16,13 @@ #include "extensions/browser/api/test/test_api.h" #include "extensions/browser/notification_types.h" #include "extensions/common/features/feature.h" +#include "extensions/test/result_catcher.h" #include "ui/message_center/message_center.h" #include "ui/message_center/notification_list.h" #include "ui/message_center/notifier_settings.h" using extensions::Extension; +using extensions::ResultCatcher; namespace utils = extension_function_test_utils; diff --git a/chrome/browser/extensions/api/omnibox/omnibox_api_browsertest.cc b/chrome/browser/extensions/api/omnibox/omnibox_api_browsertest.cc index 190eb58..63edfe6 100644 --- a/chrome/browser/extensions/api/omnibox/omnibox_api_browsertest.cc +++ b/chrome/browser/extensions/api/omnibox/omnibox_api_browsertest.cc @@ -17,9 +17,11 @@ #include "components/omnibox/autocomplete_input.h" #include "components/omnibox/autocomplete_match.h" #include "components/omnibox/autocomplete_result.h" +#include "extensions/test/result_catcher.h" #include "ui/base/window_open_disposition.h" using base::ASCIIToUTF16; +using extensions::ResultCatcher; using metrics::OmniboxEventProto; // http://crbug.com/167158 @@ -203,7 +205,7 @@ IN_PROC_BROWSER_TEST_F(OmniboxApiTest, OnInputEntered) { IN_PROC_BROWSER_TEST_F(OmniboxApiTest, DISABLED_IncognitoSplitMode) { Profile* profile = browser()->profile(); ResultCatcher catcher_incognito; - catcher_incognito.RestrictToProfile(profile->GetOffTheRecordProfile()); + catcher_incognito.RestrictToBrowserContext(profile->GetOffTheRecordProfile()); ASSERT_TRUE(RunExtensionTestIncognito("omnibox")) << message_; diff --git a/chrome/browser/extensions/api/omnibox/omnibox_api_interactive_test.cc b/chrome/browser/extensions/api/omnibox/omnibox_api_interactive_test.cc index f0c0e9d..c686d906 100644 --- a/chrome/browser/extensions/api/omnibox/omnibox_api_interactive_test.cc +++ b/chrome/browser/extensions/api/omnibox/omnibox_api_interactive_test.cc @@ -7,7 +7,7 @@ #include "chrome/browser/search_engines/template_url_service_factory.h" #include "chrome/test/base/ui_test_utils.h" #include "components/metrics/proto/omnibox_event.pb.h" - +#include "extensions/test/result_catcher.h" // Tests that the autocomplete popup doesn't reopen after accepting input for // a given query. @@ -38,7 +38,7 @@ IN_PROC_BROWSER_TEST_F(OmniboxApiTest, PopupStaysClosed) { // Quickly type another query and accept it before getting suggestions back // for the query. The popup will close after accepting input - ensure that it // does not reopen when the extension returns its suggestions. - ResultCatcher catcher; + extensions::ResultCatcher catcher; // TODO: Rather than send this second request by talking to the controller // directly, figure out how to send it via the proper calls to diff --git a/chrome/browser/extensions/api/preference/preference_apitest.cc b/chrome/browser/extensions/api/preference/preference_apitest.cc index 71b8afd..e90539a 100644 --- a/chrome/browser/extensions/api/preference/preference_apitest.cc +++ b/chrome/browser/extensions/api/preference/preference_apitest.cc @@ -17,6 +17,7 @@ #include "content/public/browser/notification_service.h" #include "extensions/browser/extension_registry.h" #include "extensions/browser/test_extension_registry_observer.h" +#include "extensions/test/result_catcher.h" namespace { @@ -206,10 +207,11 @@ IN_PROC_BROWSER_TEST_F(ExtensionPreferenceApiTest, OnChange) { } IN_PROC_BROWSER_TEST_F(ExtensionPreferenceApiTest, OnChangeSplit) { - ResultCatcher catcher; - catcher.RestrictToProfile(profile_); - ResultCatcher catcher_incognito; - catcher_incognito.RestrictToProfile(profile_->GetOffTheRecordProfile()); + extensions::ResultCatcher catcher; + catcher.RestrictToBrowserContext(profile_); + extensions::ResultCatcher catcher_incognito; + catcher_incognito.RestrictToBrowserContext( + profile_->GetOffTheRecordProfile()); // Open an incognito window. ui_test_utils::OpenURLOffTheRecord(profile_, GURL("chrome://newtab/")); diff --git a/chrome/browser/extensions/api/proxy/proxy_apitest.cc b/chrome/browser/extensions/api/proxy/proxy_apitest.cc index 1636552..f88f6bb 100644 --- a/chrome/browser/extensions/api/proxy/proxy_apitest.cc +++ b/chrome/browser/extensions/api/proxy/proxy_apitest.cc @@ -11,6 +11,7 @@ #include "chrome/common/chrome_switches.h" #include "chrome/common/pref_names.h" #include "extensions/common/extension.h" +#include "extensions/test/result_catcher.h" namespace extensions { diff --git a/chrome/browser/extensions/api/push_messaging/push_messaging_apitest.cc b/chrome/browser/extensions/api/push_messaging/push_messaging_apitest.cc index e176f32..4cef006 100644 --- a/chrome/browser/extensions/api/push_messaging/push_messaging_apitest.cc +++ b/chrome/browser/extensions/api/push_messaging/push_messaging_apitest.cc @@ -21,6 +21,7 @@ #include "components/invalidation/invalidation_service.h" #include "components/invalidation/profile_invalidation_provider.h" #include "components/keyed_service/core/keyed_service.h" +#include "extensions/test/result_catcher.h" #include "google/cacheinvalidation/types.pb.h" #include "testing/gmock/include/gmock/gmock.h" @@ -113,7 +114,7 @@ class PushMessagingApiTest : public ExtensionApiTest { IN_PROC_BROWSER_TEST_F(PushMessagingApiTest, EventDispatch) { ResultCatcher catcher; - catcher.RestrictToProfile(profile()); + catcher.RestrictToBrowserContext(profile()); const extensions::Extension* extension = LoadExtension(test_data_dir_.AppendASCII("push_messaging")); @@ -130,7 +131,7 @@ IN_PROC_BROWSER_TEST_F(PushMessagingApiTest, EventDispatch) { // that we install. IN_PROC_BROWSER_TEST_F(PushMessagingApiTest, ReceivesPush) { ResultCatcher catcher; - catcher.RestrictToProfile(profile()); + catcher.RestrictToBrowserContext(profile()); const extensions::Extension* extension = LoadExtension(test_data_dir_.AppendASCII("push_messaging")); @@ -196,7 +197,7 @@ IN_PROC_BROWSER_TEST_F(PushMessagingApiTest, Restart) { // Test that GetChannelId fails if no user is signed in. IN_PROC_BROWSER_TEST_F(PushMessagingApiTest, GetChannelId) { ResultCatcher catcher; - catcher.RestrictToProfile(profile()); + catcher.RestrictToBrowserContext(profile()); const extensions::Extension* extension = LoadExtension(test_data_dir_.AppendASCII("push_messaging")); diff --git a/chrome/browser/extensions/api/push_messaging/push_messaging_canary_test.cc b/chrome/browser/extensions/api/push_messaging/push_messaging_canary_test.cc index c8f7b40..1be1505 100644 --- a/chrome/browser/extensions/api/push_messaging/push_messaging_canary_test.cc +++ b/chrome/browser/extensions/api/push_messaging/push_messaging_canary_test.cc @@ -16,6 +16,7 @@ #include "chrome/test/base/ui_test_utils.h" #include "content/public/browser/render_frame_host.h" #include "extensions/common/extension_set.h" +#include "extensions/test/result_catcher.h" #include "net/dns/mock_host_resolver.h" namespace { @@ -144,7 +145,7 @@ IN_PROC_BROWSER_TEST_F(PushMessagingCanaryTest, MANUAL_ReceivesPush) { ASSERT_TRUE(installed_extensions->Contains(kTestExtensionId)); ResultCatcher catcher; - catcher.RestrictToProfile(profile()); + catcher.RestrictToBrowserContext(profile()); const Extension* extension = extension_service()->extensions()->GetByID(kTestExtensionId); diff --git a/chrome/browser/extensions/api/socket/socket_apitest.cc b/chrome/browser/extensions/api/socket/socket_apitest.cc index 945c450..03ba0b4 100644 --- a/chrome/browser/extensions/api/socket/socket_apitest.cc +++ b/chrome/browser/extensions/api/socket/socket_apitest.cc @@ -14,10 +14,12 @@ #include "extensions/browser/api/dns/host_resolver_wrapper.h" #include "extensions/browser/api/dns/mock_host_resolver_creator.h" #include "extensions/browser/api/socket/socket_api.h" +#include "extensions/test/result_catcher.h" #include "net/dns/mock_host_resolver.h" #include "net/test/spawned_test_server/spawned_test_server.h" using extensions::Extension; +using extensions::ResultCatcher; namespace { @@ -69,7 +71,7 @@ IN_PROC_BROWSER_TEST_F(SocketApiTest, SocketUDPExtension) { host_port_pair.set_host("LOCALhost"); ResultCatcher catcher; - catcher.RestrictToProfile(browser()->profile()); + catcher.RestrictToBrowserContext(browser()->profile()); ExtensionTestMessageListener listener("info_please", true); @@ -97,7 +99,7 @@ IN_PROC_BROWSER_TEST_F(SocketApiTest, SocketTCPExtension) { host_port_pair.set_host("lOcAlHoSt"); ResultCatcher catcher; - catcher.RestrictToProfile(browser()->profile()); + catcher.RestrictToBrowserContext(browser()->profile()); ExtensionTestMessageListener listener("info_please", true); @@ -111,7 +113,7 @@ IN_PROC_BROWSER_TEST_F(SocketApiTest, SocketTCPExtension) { IN_PROC_BROWSER_TEST_F(SocketApiTest, SocketTCPServerExtension) { ResultCatcher catcher; - catcher.RestrictToProfile(browser()->profile()); + catcher.RestrictToBrowserContext(browser()->profile()); ExtensionTestMessageListener listener("info_please", true); ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("socket/api"))); EXPECT_TRUE(listener.WaitUntilSatisfied()); @@ -137,7 +139,7 @@ IN_PROC_BROWSER_TEST_F(SocketApiTest, SocketTCPServerUnbindOnUnload) { IN_PROC_BROWSER_TEST_F(SocketApiTest, SocketMulticast) { ResultCatcher catcher; - catcher.RestrictToProfile(browser()->profile()); + catcher.RestrictToBrowserContext(browser()->profile()); ExtensionTestMessageListener listener("info_please", true); ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("socket/api"))); EXPECT_TRUE(listener.WaitUntilSatisfied()); diff --git a/chrome/browser/extensions/api/sockets_tcp/sockets_tcp_apitest.cc b/chrome/browser/extensions/api/sockets_tcp/sockets_tcp_apitest.cc index 544384b9..d1e34c7 100644 --- a/chrome/browser/extensions/api/sockets_tcp/sockets_tcp_apitest.cc +++ b/chrome/browser/extensions/api/sockets_tcp/sockets_tcp_apitest.cc @@ -16,6 +16,7 @@ #include "extensions/browser/api/dns/host_resolver_wrapper.h" #include "extensions/browser/api/dns/mock_host_resolver_creator.h" #include "extensions/browser/api/sockets_tcp/sockets_tcp_api.h" +#include "extensions/test/result_catcher.h" #include "net/dns/mock_host_resolver.h" #include "net/test/spawned_test_server/spawned_test_server.h" @@ -74,8 +75,8 @@ IN_PROC_BROWSER_TEST_F(SocketsTcpApiTest, SocketTcpExtension) { // Test that connect() is properly resolving hostnames. host_port_pair.set_host("lOcAlHoSt"); - ResultCatcher catcher; - catcher.RestrictToProfile(browser()->profile()); + extensions::ResultCatcher catcher; + catcher.RestrictToBrowserContext(browser()->profile()); ExtensionTestMessageListener listener("info_please", true); @@ -99,8 +100,8 @@ IN_PROC_BROWSER_TEST_F(SocketsTcpApiTest, SocketTcpExtensionTLS) { int https_port = https_host_port_pair.port(); ASSERT_GT(https_port, 0); - ResultCatcher catcher; - catcher.RestrictToProfile(browser()->profile()); + extensions::ResultCatcher catcher; + catcher.RestrictToBrowserContext(browser()->profile()); ExtensionTestMessageListener listener("info_please", true); diff --git a/chrome/browser/extensions/api/sockets_tcp_server/sockets_tcp_server_apitest.cc b/chrome/browser/extensions/api/sockets_tcp_server/sockets_tcp_server_apitest.cc index 8043b7b..e74eed8 100644 --- a/chrome/browser/extensions/api/sockets_tcp_server/sockets_tcp_server_apitest.cc +++ b/chrome/browser/extensions/api/sockets_tcp_server/sockets_tcp_server_apitest.cc @@ -17,6 +17,7 @@ #include "extensions/browser/api/dns/host_resolver_wrapper.h" #include "extensions/browser/api/dns/mock_host_resolver_creator.h" #include "extensions/browser/api/sockets_tcp_server/sockets_tcp_server_api.h" +#include "extensions/test/result_catcher.h" #include "net/dns/mock_host_resolver.h" #include "net/test/spawned_test_server/spawned_test_server.h" @@ -86,8 +87,8 @@ IN_PROC_BROWSER_TEST_F(SocketsTcpServerApiTest, SocketTCPCreateGood) { IN_PROC_BROWSER_TEST_F(SocketsTcpServerApiTest, SocketTCPServerExtension) { base::FilePath path = test_data_dir_.AppendASCII("sockets_tcp_server/api"); - ResultCatcher catcher; - catcher.RestrictToProfile(browser()->profile()); + extensions::ResultCatcher catcher; + catcher.RestrictToBrowserContext(browser()->profile()); ExtensionTestMessageListener listener("info_please", true); ASSERT_TRUE(LoadExtension(path)); EXPECT_TRUE(listener.WaitUntilSatisfied()); @@ -99,7 +100,7 @@ IN_PROC_BROWSER_TEST_F(SocketsTcpServerApiTest, SocketTCPServerExtension) { IN_PROC_BROWSER_TEST_F(SocketsTcpServerApiTest, SocketTCPServerUnbindOnUnload) { base::FilePath path = test_data_dir_.AppendASCII("sockets_tcp_server/unload"); - ResultCatcher catcher; + extensions::ResultCatcher catcher; const Extension* extension = LoadExtension(path); ASSERT_TRUE(extension); EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); diff --git a/chrome/browser/extensions/api/sockets_udp/sockets_udp_apitest.cc b/chrome/browser/extensions/api/sockets_udp/sockets_udp_apitest.cc index ac5bf74..1ddeb13 100644 --- a/chrome/browser/extensions/api/sockets_udp/sockets_udp_apitest.cc +++ b/chrome/browser/extensions/api/sockets_udp/sockets_udp_apitest.cc @@ -17,6 +17,7 @@ #include "extensions/browser/api/dns/host_resolver_wrapper.h" #include "extensions/browser/api/dns/mock_host_resolver_creator.h" #include "extensions/browser/api/sockets_udp/sockets_udp_api.h" +#include "extensions/test/result_catcher.h" #include "net/dns/mock_host_resolver.h" #include "net/test/spawned_test_server/spawned_test_server.h" @@ -78,8 +79,8 @@ IN_PROC_BROWSER_TEST_F(SocketsUdpApiTest, SocketsUdpExtension) { // Test that sendTo() is properly resolving hostnames. host_port_pair.set_host("LOCALhost"); - ResultCatcher catcher; - catcher.RestrictToProfile(browser()->profile()); + extensions::ResultCatcher catcher; + catcher.RestrictToBrowserContext(browser()->profile()); ExtensionTestMessageListener listener("info_please", true); @@ -92,8 +93,8 @@ IN_PROC_BROWSER_TEST_F(SocketsUdpApiTest, SocketsUdpExtension) { } IN_PROC_BROWSER_TEST_F(SocketsUdpApiTest, DISABLED_SocketsUdpMulticast) { - ResultCatcher catcher; - catcher.RestrictToProfile(browser()->profile()); + extensions::ResultCatcher catcher; + catcher.RestrictToBrowserContext(browser()->profile()); ExtensionTestMessageListener listener("info_please", true); ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("sockets_udp/api"))); EXPECT_TRUE(listener.WaitUntilSatisfied()); diff --git a/chrome/browser/extensions/api/storage/settings_apitest.cc b/chrome/browser/extensions/api/storage/settings_apitest.cc index 98a36fc..a0a886b 100644 --- a/chrome/browser/extensions/api/storage/settings_apitest.cc +++ b/chrome/browser/extensions/api/storage/settings_apitest.cc @@ -18,6 +18,7 @@ #include "extensions/browser/api/storage/storage_frontend.h" #include "extensions/browser/extension_system.h" #include "extensions/common/value_builder.h" +#include "extensions/test/result_catcher.h" #include "sync/api/fake_sync_change_processor.h" #include "sync/api/sync_change.h" #include "sync/api/sync_change_processor.h" @@ -224,8 +225,8 @@ IN_PROC_BROWSER_TEST_F(ExtensionSettingsApiTest, SplitModeIncognito) { // We need 2 ResultCatchers because we'll be running the same test in both // regular and incognito mode. ResultCatcher catcher, catcher_incognito; - catcher.RestrictToProfile(browser()->profile()); - catcher_incognito.RestrictToProfile( + catcher.RestrictToBrowserContext(browser()->profile()); + catcher_incognito.RestrictToBrowserContext( browser()->profile()->GetOffTheRecordProfile()); LoadAndReplyWhenSatisfied(SYNC, @@ -248,8 +249,8 @@ IN_PROC_BROWSER_TEST_F(ExtensionSettingsApiTest, // We need 2 ResultCatchers because we'll be running the same test in both // regular and incognito mode. ResultCatcher catcher, catcher_incognito; - catcher.RestrictToProfile(browser()->profile()); - catcher_incognito.RestrictToProfile( + catcher.RestrictToBrowserContext(browser()->profile()); + catcher_incognito.RestrictToBrowserContext( browser()->profile()->GetOffTheRecordProfile()); LoadAndReplyWhenSatisfied(SYNC, @@ -271,8 +272,8 @@ IN_PROC_BROWSER_TEST_F(ExtensionSettingsApiTest, // We need 2 ResultCatchers because we'll be running the same test in both // regular and incognito mode. ResultCatcher catcher, catcher_incognito; - catcher.RestrictToProfile(browser()->profile()); - catcher_incognito.RestrictToProfile( + catcher.RestrictToBrowserContext(browser()->profile()); + catcher_incognito.RestrictToBrowserContext( browser()->profile()->GetOffTheRecordProfile()); LoadAndReplyWhenSatisfied(SYNC, @@ -322,8 +323,8 @@ IN_PROC_BROWSER_TEST_F(ExtensionSettingsApiTest, // We need 2 ResultCatchers because we'll be running the same test in both // regular and incognito mode. ResultCatcher catcher, catcher_incognito; - catcher.RestrictToProfile(browser()->profile()); - catcher_incognito.RestrictToProfile( + catcher.RestrictToBrowserContext(browser()->profile()); + catcher_incognito.RestrictToBrowserContext( browser()->profile()->GetOffTheRecordProfile()); const Extension* extension = @@ -367,8 +368,8 @@ IN_PROC_BROWSER_TEST_F(ExtensionSettingsApiTest, // We need 2 ResultCatchers because we'll be running the same test in both // regular and incognito mode. ResultCatcher catcher, catcher_incognito; - catcher.RestrictToProfile(browser()->profile()); - catcher_incognito.RestrictToProfile( + catcher.RestrictToBrowserContext(browser()->profile()); + catcher_incognito.RestrictToBrowserContext( browser()->profile()->GetOffTheRecordProfile()); const Extension* extension = diff --git a/chrome/browser/extensions/api/streams_private/streams_private_apitest.cc b/chrome/browser/extensions/api/streams_private/streams_private_apitest.cc index 00b5b4e..3805a38 100644 --- a/chrome/browser/extensions/api/streams_private/streams_private_apitest.cc +++ b/chrome/browser/extensions/api/streams_private/streams_private_apitest.cc @@ -23,6 +23,7 @@ #include "content/public/test/download_test_observer.h" #include "extensions/browser/event_router.h" #include "extensions/browser/extension_system.h" +#include "extensions/test/result_catcher.h" #include "net/dns/mock_host_resolver.h" #include "net/test/embedded_test_server/embedded_test_server.h" #include "net/test/embedded_test_server/http_request.h" @@ -38,6 +39,7 @@ using content::ResourceController; using content::WebContents; using extensions::Event; using extensions::ExtensionSystem; +using extensions::ResultCatcher; using net::test_server::BasicHttpResponse; using net::test_server::HttpRequest; using net::test_server::HttpResponse; diff --git a/chrome/browser/extensions/api/system_indicator/system_indicator_apitest.cc b/chrome/browser/extensions/api/system_indicator/system_indicator_apitest.cc index 8e58ca2..18a1933 100644 --- a/chrome/browser/extensions/api/system_indicator/system_indicator_apitest.cc +++ b/chrome/browser/extensions/api/system_indicator/system_indicator_apitest.cc @@ -13,6 +13,7 @@ #include "extensions/browser/process_manager.h" #include "extensions/common/extension.h" #include "extensions/common/switches.h" +#include "extensions/test/result_catcher.h" class SystemIndicatorApiTest : public ExtensionApiTest { public: @@ -53,7 +54,7 @@ IN_PROC_BROWSER_TEST_F(SystemIndicatorApiTest, SystemIndicator) { extensions::SystemIndicatorManager* manager = extensions::SystemIndicatorManagerFactory::GetForProfile(profile()); if (manager) { - ResultCatcher catcher; + extensions::ResultCatcher catcher; const extensions::Extension* extension = LoadExtensionAndWait("system_indicator/unloaded"); diff --git a/chrome/browser/extensions/api/system_storage/system_storage_apitest.cc b/chrome/browser/extensions/api/system_storage/system_storage_apitest.cc index c0f62b0..c29e1c1 100644 --- a/chrome/browser/extensions/api/system_storage/system_storage_apitest.cc +++ b/chrome/browser/extensions/api/system_storage/system_storage_apitest.cc @@ -12,6 +12,7 @@ #include "components/storage_monitor/storage_monitor.h" #include "components/storage_monitor/test_storage_monitor.h" #include "extensions/browser/api/system_storage/storage_info_provider.h" +#include "extensions/test/result_catcher.h" namespace { @@ -121,7 +122,7 @@ IN_PROC_BROWSER_TEST_F(SystemStorageApiTest, Storage) { } IN_PROC_BROWSER_TEST_F(SystemStorageApiTest, StorageAttachment) { - ResultCatcher catcher; + extensions::ResultCatcher catcher; ExtensionTestMessageListener attach_listener("attach", false); ExtensionTestMessageListener detach_listener("detach", false); diff --git a/chrome/browser/extensions/api/tab_capture/tab_capture_apitest.cc b/chrome/browser/extensions/api/tab_capture/tab_capture_apitest.cc index ceeaa91..975a40b 100644 --- a/chrome/browser/extensions/api/tab_capture/tab_capture_apitest.cc +++ b/chrome/browser/extensions/api/tab_capture/tab_capture_apitest.cc @@ -15,6 +15,7 @@ #include "content/public/browser/render_process_host.h" #include "extensions/browser/extension_registry.h" #include "extensions/common/switches.h" +#include "extensions/test/result_catcher.h" #if defined(OS_WIN) #include "base/win/windows_version.h" @@ -127,7 +128,7 @@ IN_PROC_BROWSER_TEST_F(TabCaptureApiTest, MAYBE_GetUserMediaTest) { main_frame->GetRoutingID())); ResultCatcher catcher; - catcher.RestrictToProfile(browser()->profile()); + catcher.RestrictToBrowserContext(browser()->profile()); EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); } @@ -177,7 +178,7 @@ IN_PROC_BROWSER_TEST_F(TabCaptureApiTest, MAYBE_ActiveTabPermission) { before_whitelist_extension.Reply(""); ResultCatcher catcher; - catcher.RestrictToProfile(browser()->profile()); + catcher.RestrictToBrowserContext(browser()->profile()); EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); } @@ -228,7 +229,7 @@ IN_PROC_BROWSER_TEST_F(TabCaptureApiTest, MAYBE_FullscreenEvents) { fullscreen_entered.Reply(""); ResultCatcher catcher; - catcher.RestrictToProfile(browser()->profile()); + catcher.RestrictToBrowserContext(browser()->profile()); EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); } @@ -261,7 +262,7 @@ IN_PROC_BROWSER_TEST_F(TabCaptureApiTest, MAYBE_GrantForChromePages) { before_open_tab.Reply(""); ResultCatcher catcher; - catcher.RestrictToProfile(browser()->profile()); + catcher.RestrictToBrowserContext(browser()->profile()); EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); } diff --git a/chrome/browser/extensions/api/web_navigation/web_navigation_apitest.cc b/chrome/browser/extensions/api/web_navigation/web_navigation_apitest.cc index e984a11..efc9a12 100644 --- a/chrome/browser/extensions/api/web_navigation/web_navigation_apitest.cc +++ b/chrome/browser/extensions/api/web_navigation/web_navigation_apitest.cc @@ -42,6 +42,7 @@ #include "content/public/test/browser_test_utils.h" #include "extensions/browser/extension_system.h" #include "extensions/common/switches.h" +#include "extensions/test/result_catcher.h" #include "net/dns/mock_host_resolver.h" #include "net/test/embedded_test_server/embedded_test_server.h" #include "third_party/WebKit/public/web/WebContextMenuData.h" diff --git a/chrome/browser/extensions/api/web_request/web_request_apitest.cc b/chrome/browser/extensions/api/web_request/web_request_apitest.cc index 206eb7b..36694b5 100644 --- a/chrome/browser/extensions/api/web_request/web_request_apitest.cc +++ b/chrome/browser/extensions/api/web_request/web_request_apitest.cc @@ -20,12 +20,14 @@ #include "content/public/test/browser_test_utils.h" #include "extensions/browser/extension_system.h" #include "extensions/common/features/feature.h" +#include "extensions/test/result_catcher.h" #include "net/dns/mock_host_resolver.h" #include "net/test/embedded_test_server/embedded_test_server.h" #include "third_party/WebKit/public/web/WebInputEvent.h" using content::WebContents; using extensions::Feature; +using extensions::ResultCatcher; namespace { @@ -181,9 +183,9 @@ void ExtensionWebRequestApiTest::RunPermissionTest( const char* expected_content_regular_window, const char* exptected_content_incognito_window) { ResultCatcher catcher; - catcher.RestrictToProfile(browser()->profile()); + catcher.RestrictToBrowserContext(browser()->profile()); ResultCatcher catcher_incognito; - catcher_incognito.RestrictToProfile( + catcher_incognito.RestrictToBrowserContext( browser()->profile()->GetOffTheRecordProfile()); ExtensionTestMessageListener listener("done", true); diff --git a/chrome/browser/extensions/content_script_apitest.cc b/chrome/browser/extensions/content_script_apitest.cc index aad743d..58e4cbf 100644 --- a/chrome/browser/extensions/content_script_apitest.cc +++ b/chrome/browser/extensions/content_script_apitest.cc @@ -15,6 +15,7 @@ #include "content/public/test/browser_test_utils.h" #include "extensions/browser/notification_types.h" #include "extensions/common/extension.h" +#include "extensions/test/result_catcher.h" #include "net/dns/mock_host_resolver.h" #include "net/test/embedded_test_server/embedded_test_server.h" #include "url/gurl.h" diff --git a/chrome/browser/extensions/extension_apitest.cc b/chrome/browser/extensions/extension_apitest.cc index 7a89e3d..0a6deb8 100644 --- a/chrome/browser/extensions/extension_apitest.cc +++ b/chrome/browser/extensions/extension_apitest.cc @@ -13,13 +13,11 @@ #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/extensions/application_launch.h" #include "chrome/test/base/ui_test_utils.h" -#include "content/public/browser/notification_registrar.h" -#include "content/public/browser/notification_service.h" #include "extensions/browser/api/test/test_api.h" #include "extensions/browser/extension_system.h" -#include "extensions/browser/notification_types.h" #include "extensions/common/extension.h" #include "extensions/common/extension_set.h" +#include "extensions/test/result_catcher.h" #include "net/base/escape.h" #include "net/base/filename_util.h" #include "net/test/embedded_test_server/embedded_test_server.h" @@ -141,73 +139,6 @@ ExtensionApiTest::ExtensionApiTest() { ExtensionApiTest::~ExtensionApiTest() {} -ExtensionApiTest::ResultCatcher::ResultCatcher() - : profile_restriction_(NULL), - waiting_(false) { - registrar_.Add(this, - extensions::NOTIFICATION_EXTENSION_TEST_PASSED, - content::NotificationService::AllSources()); - registrar_.Add(this, - extensions::NOTIFICATION_EXTENSION_TEST_FAILED, - content::NotificationService::AllSources()); -} - -ExtensionApiTest::ResultCatcher::~ResultCatcher() { -} - -bool ExtensionApiTest::ResultCatcher::GetNextResult() { - // Depending on the tests, multiple results can come in from a single call - // to RunMessageLoop(), so we maintain a queue of results and just pull them - // off as the test calls this, going to the run loop only when the queue is - // empty. - if (results_.empty()) { - waiting_ = true; - content::RunMessageLoop(); - waiting_ = false; - } - - if (!results_.empty()) { - bool ret = results_.front(); - results_.pop_front(); - message_ = messages_.front(); - messages_.pop_front(); - return ret; - } - - NOTREACHED(); - return false; -} - -void ExtensionApiTest::ResultCatcher::Observe( - int type, const content::NotificationSource& source, - const content::NotificationDetails& details) { - if (profile_restriction_ && - content::Source<Profile>(source).ptr() != profile_restriction_) { - return; - } - - switch (type) { - case extensions::NOTIFICATION_EXTENSION_TEST_PASSED: - VLOG(1) << "Got EXTENSION_TEST_PASSED notification."; - results_.push_back(true); - messages_.push_back(std::string()); - if (waiting_) - base::MessageLoopForUI::current()->Quit(); - break; - - case extensions::NOTIFICATION_EXTENSION_TEST_FAILED: - VLOG(1) << "Got EXTENSION_TEST_FAILED notification."; - results_.push_back(false); - messages_.push_back(*(content::Details<std::string>(details).ptr())); - if (waiting_) - base::MessageLoopForUI::current()->Quit(); - break; - - default: - NOTREACHED(); - } -} - void ExtensionApiTest::SetUpInProcessBrowserTestFixture() { DCHECK(!test_config_.get()) << "Previous test did not clear config state."; test_config_.reset(new base::DictionaryValue()); @@ -328,7 +259,7 @@ bool ExtensionApiTest::RunExtensionTestImpl(const std::string& extension_name, if (custom_arg && custom_arg[0]) test_config_->SetString(kTestCustomArg, custom_arg); - ResultCatcher catcher; + extensions::ResultCatcher catcher; DCHECK(!extension_name.empty() || !page_url.empty()) << "extension_name and page_url cannot both be empty"; diff --git a/chrome/browser/extensions/extension_apitest.h b/chrome/browser/extensions/extension_apitest.h index cba4f5f..4664878 100644 --- a/chrome/browser/extensions/extension_apitest.h +++ b/chrome/browser/extensions/extension_apitest.h @@ -64,47 +64,7 @@ class ExtensionApiTest : public ExtensionBrowserTest { virtual ~ExtensionApiTest(); protected: - // Helper class that observes tests failing or passing. Observation starts - // when the class is constructed. Get the next result by calling - // GetNextResult() and message() if GetNextResult() return false. If there - // are no results, this method will pump the UI message loop until one is - // received. - // DEPRECATED: Use extensions/test/result_catcher.h instead. - class ResultCatcher : public content::NotificationObserver { - public: - ResultCatcher(); - virtual ~ResultCatcher(); - - // Pumps the UI loop until a notification is received that an API test - // succeeded or failed. Returns true if the test succeeded, false otherwise. - bool GetNextResult(); - - void RestrictToProfile(Profile* profile) { profile_restriction_ = profile; } - - const std::string& message() { return message_; } - - private: - virtual void Observe(int type, - const content::NotificationSource& source, - const content::NotificationDetails& details) OVERRIDE; - - content::NotificationRegistrar registrar_; - - // A sequential list of pass/fail notifications from the test extension(s). - std::deque<bool> results_; - - // If it failed, what was the error message? - std::deque<std::string> messages_; - std::string message_; - - // If non-NULL, we will listen to events from this profile only. - Profile* profile_restriction_; - - // True if we're in a nested message loop waiting for results from - // the extension. - bool waiting_; - }; - + // InProcessBrowserTest: virtual void SetUpInProcessBrowserTestFixture() OVERRIDE; virtual void TearDownInProcessBrowserTestFixture() OVERRIDE; diff --git a/chrome/browser/extensions/extension_bindings_apitest.cc b/chrome/browser/extensions/extension_bindings_apitest.cc index 3d8304c..ed12130 100644 --- a/chrome/browser/extensions/extension_bindings_apitest.cc +++ b/chrome/browser/extensions/extension_bindings_apitest.cc @@ -13,6 +13,7 @@ #include "extensions/browser/extension_host.h" #include "extensions/browser/extension_system.h" #include "extensions/browser/process_manager.h" +#include "extensions/test/result_catcher.h" namespace extensions { namespace { diff --git a/chrome/browser/extensions/extension_commands_global_registry_apitest.cc b/chrome/browser/extensions/extension_commands_global_registry_apitest.cc index d6c60f3..cbe6281 100644 --- a/chrome/browser/extensions/extension_commands_global_registry_apitest.cc +++ b/chrome/browser/extensions/extension_commands_global_registry_apitest.cc @@ -8,6 +8,7 @@ #include "chrome/browser/ui/tabs/tab_strip_model.h" #include "chrome/test/base/interactive_test_utils.h" #include "content/public/test/browser_test_utils.h" +#include "extensions/test/result_catcher.h" #include "ui/base/base_window.h" #include "ui/base/test/ui_controls.h" diff --git a/chrome/browser/extensions/extension_incognito_apitest.cc b/chrome/browser/extensions/extension_incognito_apitest.cc index 36642c9..bd6df72 100644 --- a/chrome/browser/extensions/extension_incognito_apitest.cc +++ b/chrome/browser/extensions/extension_incognito_apitest.cc @@ -14,10 +14,12 @@ #include "chrome/test/base/ui_test_utils.h" #include "content/public/browser/web_contents.h" #include "content/public/test/browser_test_utils.h" +#include "extensions/test/result_catcher.h" #include "net/dns/mock_host_resolver.h" #include "net/test/embedded_test_server/embedded_test_server.h" using content::WebContents; +using extensions::ResultCatcher; IN_PROC_BROWSER_TEST_F(ExtensionApiTest, IncognitoNoScript) { ASSERT_TRUE(StartEmbeddedTestServer()); @@ -127,9 +129,9 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, DISABLED_IncognitoSplitMode) { // We need 2 ResultCatchers because we'll be running the same test in both // regular and incognito mode. ResultCatcher catcher; - catcher.RestrictToProfile(browser()->profile()); + catcher.RestrictToBrowserContext(browser()->profile()); ResultCatcher catcher_incognito; - catcher_incognito.RestrictToProfile( + catcher_incognito.RestrictToBrowserContext( browser()->profile()->GetOffTheRecordProfile()); ExtensionTestMessageListener listener("waiting", true); diff --git a/chrome/browser/extensions/extension_keybinding_apitest.cc b/chrome/browser/extensions/extension_keybinding_apitest.cc index 3b7d4a2..a3796bd 100644 --- a/chrome/browser/extensions/extension_keybinding_apitest.cc +++ b/chrome/browser/extensions/extension_keybinding_apitest.cc @@ -23,6 +23,7 @@ #include "extensions/common/feature_switch.h" #include "extensions/common/manifest_constants.h" #include "extensions/common/permissions/permissions_data.h" +#include "extensions/test/result_catcher.h" using content::WebContents; diff --git a/chrome/browser/extensions/extension_override_apitest.cc b/chrome/browser/extensions/extension_override_apitest.cc index db21578..b190d2e 100644 --- a/chrome/browser/extensions/extension_override_apitest.cc +++ b/chrome/browser/extensions/extension_override_apitest.cc @@ -16,6 +16,7 @@ #include "content/public/browser/navigation_entry.h" #include "content/public/browser/web_contents.h" #include "extensions/common/constants.h" +#include "extensions/test/result_catcher.h" using content::WebContents; @@ -50,7 +51,7 @@ class ExtensionOverrideTest : public ExtensionApiTest { IN_PROC_BROWSER_TEST_F(ExtensionOverrideTest, OverrideNewtab) { ASSERT_TRUE(RunExtensionTest("override/newtab")) << message_; { - ResultCatcher catcher; + extensions::ResultCatcher catcher; // Navigate to the new tab page. The overridden new tab page // will call chrome.test.notifyPass() . ui_test_utils::NavigateToURL(browser(), GURL("chrome://newtab/")); @@ -95,7 +96,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionOverrideTest, MAYBE_OverrideNewtabIncognito) { IN_PROC_BROWSER_TEST_F(ExtensionOverrideTest, MAYBE_OverrideHistory) { ASSERT_TRUE(RunExtensionTest("override/history")) << message_; { - ResultCatcher catcher; + extensions::ResultCatcher catcher; // Navigate to the history page. The overridden history page // will call chrome.test.notifyPass() . ui_test_utils::NavigateToURL(browser(), GURL("chrome://history/")); diff --git a/chrome/browser/extensions/lazy_background_page_apitest.cc b/chrome/browser/extensions/lazy_background_page_apitest.cc index abf25cc..19962e2 100644 --- a/chrome/browser/extensions/lazy_background_page_apitest.cc +++ b/chrome/browser/extensions/lazy_background_page_apitest.cc @@ -31,11 +31,13 @@ #include "extensions/browser/extension_system.h" #include "extensions/common/extension.h" #include "extensions/common/switches.h" +#include "extensions/test/result_catcher.h" #include "net/dns/mock_host_resolver.h" #include "net/test/embedded_test_server/embedded_test_server.h" #include "url/gurl.h" using extensions::Extension; +using extensions::ResultCatcher; namespace { @@ -485,7 +487,7 @@ IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, OnUnload) { // the event page is not loaded. IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, EventDispatchToTab) { ResultCatcher catcher; - catcher.RestrictToProfile(browser()->profile()); + catcher.RestrictToBrowserContext(browser()->profile()); const extensions::Extension* extension = LoadExtensionAndWait("event_dispatch_to_tab"); diff --git a/chrome/browser/extensions/stubs_apitest.cc b/chrome/browser/extensions/stubs_apitest.cc index 2c16ce83..052a2db 100644 --- a/chrome/browser/extensions/stubs_apitest.cc +++ b/chrome/browser/extensions/stubs_apitest.cc @@ -5,6 +5,7 @@ #include "chrome/browser/extensions/extension_apitest.h" #include "chrome/common/chrome_paths.h" #include "chrome/test/base/ui_test_utils.h" +#include "extensions/test/result_catcher.h" #include "net/test/embedded_test_server/embedded_test_server.h" #include "url/gurl.h" @@ -26,7 +27,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MAYBE_Stubs) { GURL url(embedded_test_server()->GetURL("/extensions/test_file.html")); ui_test_utils::NavigateToURL(browser(), url); - ResultCatcher catcher; + extensions::ResultCatcher catcher; ASSERT_TRUE(catcher.GetNextResult()); } diff --git a/chrome/browser/extensions/window_open_apitest.cc b/chrome/browser/extensions/window_open_apitest.cc index adf472f..b841b74 100644 --- a/chrome/browser/extensions/window_open_apitest.cc +++ b/chrome/browser/extensions/window_open_apitest.cc @@ -29,6 +29,7 @@ #include "extensions/common/constants.h" #include "extensions/common/extension.h" #include "extensions/common/switches.h" +#include "extensions/test/result_catcher.h" #include "net/dns/mock_host_resolver.h" #include "net/test/embedded_test_server/embedded_test_server.h" #include "testing/gtest/include/gtest/gtest.h" @@ -51,7 +52,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, DISABLED_WindowOpen) { CommandLine::ForCurrentProcess()->AppendSwitch( extensions::switches::kEnableExperimentalExtensionApis); - ResultCatcher catcher; + extensions::ResultCatcher catcher; ASSERT_TRUE(LoadExtensionIncognito(test_data_dir_ .AppendASCII("window_open").AppendASCII("spanning"))); EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); diff --git a/chrome/browser/guest_view/extension_options/extension_options_apitest.cc b/chrome/browser/guest_view/extension_options/extension_options_apitest.cc index 77027b1..af98ead 100644 --- a/chrome/browser/guest_view/extension_options/extension_options_apitest.cc +++ b/chrome/browser/guest_view/extension_options/extension_options_apitest.cc @@ -8,6 +8,7 @@ #include "chrome/test/base/ui_test_utils.h" #include "extensions/common/feature_switch.h" #include "extensions/common/switches.h" +#include "extensions/test/result_catcher.h" using extensions::Extension; using extensions::FeatureSwitch; @@ -56,7 +57,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionOptionsApiTest, embedded->id().c_str()); ExecuteScriptInBackgroundPage(embedder->id(), script); - ResultCatcher catcher; + extensions::ResultCatcher catcher; ui_test_utils::NavigateToURL(browser(), embedder->GetResourceURL("test.html")); ASSERT_TRUE(catcher.GetNextResult()); diff --git a/chrome/browser/prerender/prerender_browsertest.cc b/chrome/browser/prerender/prerender_browsertest.cc index 73b94ad..0b0752b 100644 --- a/chrome/browser/prerender/prerender_browsertest.cc +++ b/chrome/browser/prerender/prerender_browsertest.cc @@ -83,6 +83,7 @@ #include "content/public/test/test_utils.h" #include "content/test/net/url_request_mock_http_job.h" #include "extensions/common/switches.h" +#include "extensions/test/result_catcher.h" #include "net/base/escape.h" #include "net/cert/x509_certificate.h" #include "net/dns/mock_host_resolver.h" @@ -3538,7 +3539,7 @@ IN_PROC_BROWSER_TEST_F(PrerenderBrowserTestWithExtensions, WebNavigation) { // Wait for the extension to set itself up and return control to us. ASSERT_TRUE(RunExtensionTest("webnavigation/prerender")) << message_; - ResultCatcher catcher; + extensions::ResultCatcher catcher; PrerenderTestURL("files/prerender/prerender_page.html", FINAL_STATUS_USED, 1); @@ -3559,7 +3560,7 @@ IN_PROC_BROWSER_TEST_F(PrerenderBrowserTestWithExtensions, TabsApi) { // Wait for the extension to set itself up and return control to us. ASSERT_TRUE(RunExtensionTest("tabs/on_replaced")) << message_; - ResultCatcher catcher; + extensions::ResultCatcher catcher; PrerenderTestURL("files/prerender/prerender_page.html", FINAL_STATUS_USED, 1); @@ -3593,7 +3594,7 @@ IN_PROC_BROWSER_TEST_F(PrerenderBrowserTestWithExtensions, StreamsTest) { // navigation had prerender not intercepted it. // streams_private/handle_mime_type reports success if it has handled the // application/msword type. - ResultCatcher catcher; + extensions::ResultCatcher catcher; NavigateToDestURL(); EXPECT_TRUE(catcher.GetNextResult()); } diff --git a/chrome/browser/resources/pdf/pdf_extension_test.cc b/chrome/browser/resources/pdf/pdf_extension_test.cc index 4233d74..775fcc8 100644 --- a/chrome/browser/resources/pdf/pdf_extension_test.cc +++ b/chrome/browser/resources/pdf/pdf_extension_test.cc @@ -13,6 +13,7 @@ #include "chrome/common/extensions/manifest_handlers/mime_types_handler.h" #include "chrome/test/base/ui_test_utils.h" #include "content/public/test/browser_test_utils.h" +#include "extensions/test/result_catcher.h" #include "grit/browser_resources.h" #include "net/test/embedded_test_server/embedded_test_server.h" @@ -55,7 +56,7 @@ class PDFExtensionTest : public ExtensionApiTest { ASSERT_TRUE(MimeTypesHandler::GetHandler( extension)->CanHandleMIMEType("application/pdf")); - ResultCatcher catcher; + extensions::ResultCatcher catcher; GURL url(embedded_test_server()->GetURL("/pdf/test.pdf")); GURL extension_url( diff --git a/extensions/DEPS b/extensions/DEPS index 91be1a7..e6b483f 100644 --- a/extensions/DEPS +++ b/extensions/DEPS @@ -7,6 +7,7 @@ include_rules = [ "+content/public/common", "+content/public/test", "+crypto", + "+extensions/test", "+grit/extensions_renderer_resources.h", "+grit/extensions_resources.h", "+mojo/public", diff --git a/extensions/browser/api/bluetooth/bluetooth_apitest.cc b/extensions/browser/api/bluetooth/bluetooth_apitest.cc index b62982f..866cb0b 100644 --- a/extensions/browser/api/bluetooth/bluetooth_apitest.cc +++ b/extensions/browser/api/bluetooth/bluetooth_apitest.cc @@ -19,6 +19,7 @@ #include "device/bluetooth/test/mock_bluetooth_discovery_session.h" #include "extensions/browser/api/bluetooth/bluetooth_api.h" #include "extensions/browser/api/bluetooth/bluetooth_event_router.h" +#include "extensions/test/result_catcher.h" #include "testing/gmock/include/gmock/gmock.h" using device::BluetoothAdapter; @@ -29,6 +30,7 @@ using device::MockBluetoothAdapter; using device::MockBluetoothDevice; using device::MockBluetoothDiscoverySession; using extensions::Extension; +using extensions::ResultCatcher; namespace utils = extension_function_test_utils; namespace api = extensions::core_api; @@ -142,7 +144,7 @@ IN_PROC_BROWSER_TEST_F(BluetoothApiTest, GetAdapterState) { IN_PROC_BROWSER_TEST_F(BluetoothApiTest, DeviceEvents) { ResultCatcher catcher; - catcher.RestrictToProfile(browser()->profile()); + catcher.RestrictToBrowserContext(browser()->profile()); ASSERT_TRUE(LoadExtension( test_data_dir_.AppendASCII("bluetooth/device_events"))); @@ -230,7 +232,7 @@ IN_PROC_BROWSER_TEST_F(BluetoothApiTest, DiscoveryCallback) { .WillOnce(testing::Invoke(StopDiscoverySessionCallback)); ResultCatcher catcher; - catcher.RestrictToProfile(browser()->profile()); + catcher.RestrictToBrowserContext(browser()->profile()); ExtensionTestMessageListener discovery_started("ready", true); ASSERT_TRUE(LoadExtension( @@ -270,7 +272,7 @@ IN_PROC_BROWSER_TEST_F(BluetoothApiTest, DiscoveryInProgress) { event_router()->DeviceAdded(mock_adapter_, device1_.get()); ResultCatcher catcher; - catcher.RestrictToProfile(browser()->profile()); + catcher.RestrictToBrowserContext(browser()->profile()); mock_session_.reset(new testing::NiceMock<MockBluetoothDiscoverySession>()); MockBluetoothDiscoverySession* session = mock_session_.get(); @@ -305,7 +307,7 @@ IN_PROC_BROWSER_TEST_F(BluetoothApiTest, DiscoveryInProgress) { IN_PROC_BROWSER_TEST_F(BluetoothApiTest, OnAdapterStateChanged) { ResultCatcher catcher; - catcher.RestrictToProfile(browser()->profile()); + catcher.RestrictToBrowserContext(browser()->profile()); // Load and wait for setup ExtensionTestMessageListener listener("ready", true); @@ -357,7 +359,7 @@ IN_PROC_BROWSER_TEST_F(BluetoothApiTest, OnAdapterStateChanged) { IN_PROC_BROWSER_TEST_F(BluetoothApiTest, GetDevices) { ResultCatcher catcher; - catcher.RestrictToProfile(browser()->profile()); + catcher.RestrictToBrowserContext(browser()->profile()); BluetoothAdapter::ConstDeviceList devices; devices.push_back(device1_.get()); @@ -380,7 +382,7 @@ IN_PROC_BROWSER_TEST_F(BluetoothApiTest, GetDevices) { IN_PROC_BROWSER_TEST_F(BluetoothApiTest, GetDevice) { ResultCatcher catcher; - catcher.RestrictToProfile(browser()->profile()); + catcher.RestrictToBrowserContext(browser()->profile()); EXPECT_CALL(*mock_adapter_, GetDevice(device1_->GetAddress())) .WillOnce(testing::Return(device1_.get())); @@ -401,7 +403,7 @@ IN_PROC_BROWSER_TEST_F(BluetoothApiTest, GetDevice) { IN_PROC_BROWSER_TEST_F(BluetoothApiTest, DeviceInfo) { ResultCatcher catcher; - catcher.RestrictToProfile(browser()->profile()); + catcher.RestrictToBrowserContext(browser()->profile()); // Set up the first device object to reflect a real-world device. BluetoothAdapter::ConstDeviceList devices; diff --git a/extensions/browser/api/bluetooth_low_energy/bluetooth_low_energy_apitest.cc b/extensions/browser/api/bluetooth_low_energy/bluetooth_low_energy_apitest.cc index ac09e45..e09f4141 100644 --- a/extensions/browser/api/bluetooth_low_energy/bluetooth_low_energy_apitest.cc +++ b/extensions/browser/api/bluetooth_low_energy/bluetooth_low_energy_apitest.cc @@ -15,6 +15,7 @@ #include "device/bluetooth/test/mock_bluetooth_gatt_service.h" #include "extensions/browser/api/bluetooth_low_energy/bluetooth_low_energy_api.h" #include "extensions/browser/api/bluetooth_low_energy/bluetooth_low_energy_event_router.h" +#include "extensions/test/result_catcher.h" #include "testing/gmock/include/gmock/gmock.h" using device::BluetoothUUID; @@ -33,6 +34,7 @@ using device::MockBluetoothGattDescriptor; using device::MockBluetoothGattService; using device::MockBluetoothGattNotifySession; using extensions::BluetoothLowEnergyEventRouter; +using extensions::ResultCatcher; using testing::Invoke; using testing::Return; using testing::ReturnRef; @@ -260,7 +262,7 @@ BluetoothGattConnection* CreateGattConnection( IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, GetServices) { ResultCatcher catcher; - catcher.RestrictToProfile(browser()->profile()); + catcher.RestrictToBrowserContext(browser()->profile()); std::vector<BluetoothGattService*> services; services.push_back(service0_.get()); @@ -289,7 +291,7 @@ IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, GetServices) { IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, GetService) { ResultCatcher catcher; - catcher.RestrictToProfile(browser()->profile()); + catcher.RestrictToBrowserContext(browser()->profile()); event_router()->GattServiceAdded( mock_adapter_, device0_.get(), service0_.get()); @@ -320,7 +322,7 @@ IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, GetService) { IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, ServiceEvents) { ResultCatcher catcher; - catcher.RestrictToProfile(browser()->profile()); + catcher.RestrictToBrowserContext(browser()->profile()); // Load the extension and let it set up. ExtensionTestMessageListener listener("ready", true); @@ -356,7 +358,7 @@ IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, ServiceEvents) { IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, GetRemovedService) { ResultCatcher catcher; - catcher.RestrictToProfile(browser()->profile()); + catcher.RestrictToBrowserContext(browser()->profile()); // Load the extension and let it set up. ASSERT_TRUE(LoadExtension( @@ -401,7 +403,7 @@ IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, GetRemovedService) { IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, GetIncludedServices) { ResultCatcher catcher; - catcher.RestrictToProfile(browser()->profile()); + catcher.RestrictToBrowserContext(browser()->profile()); ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII( "bluetooth_low_energy/get_included_services"))); @@ -443,7 +445,7 @@ IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, GetIncludedServices) { IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, GetCharacteristics) { ResultCatcher catcher; - catcher.RestrictToProfile(browser()->profile()); + catcher.RestrictToBrowserContext(browser()->profile()); std::vector<BluetoothGattCharacteristic*> characteristics; characteristics.push_back(chrc0_.get()); @@ -477,7 +479,7 @@ IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, GetCharacteristics) { IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, GetCharacteristic) { ResultCatcher catcher; - catcher.RestrictToProfile(browser()->profile()); + catcher.RestrictToBrowserContext(browser()->profile()); event_router()->GattServiceAdded( mock_adapter_, device0_.get(), service0_.get()); @@ -515,7 +517,7 @@ IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, GetCharacteristic) { IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, CharacteristicProperties) { ResultCatcher catcher; - catcher.RestrictToProfile(browser()->profile()); + catcher.RestrictToBrowserContext(browser()->profile()); event_router()->GattServiceAdded( mock_adapter_, device0_.get(), service0_.get()); @@ -575,7 +577,7 @@ IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, CharacteristicProperties) { IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, GetRemovedCharacteristic) { ResultCatcher catcher; - catcher.RestrictToProfile(browser()->profile()); + catcher.RestrictToBrowserContext(browser()->profile()); EXPECT_CALL(*mock_adapter_, GetDevice(_)) .Times(1) @@ -619,7 +621,7 @@ IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, GetRemovedCharacteristic) { IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, CharacteristicValueChanged) { ResultCatcher catcher; - catcher.RestrictToProfile(browser()->profile()); + catcher.RestrictToBrowserContext(browser()->profile()); // Cause events to be sent to the extension. event_router()->GattServiceAdded( @@ -688,7 +690,7 @@ IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, CharacteristicValueChanged) { IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, ReadCharacteristicValue) { ResultCatcher catcher; - catcher.RestrictToProfile(browser()->profile()); + catcher.RestrictToBrowserContext(browser()->profile()); event_router()->GattServiceAdded( mock_adapter_, device0_.get(), service0_.get()); @@ -728,7 +730,7 @@ IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, ReadCharacteristicValue) { IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, WriteCharacteristicValue) { ResultCatcher catcher; - catcher.RestrictToProfile(browser()->profile()); + catcher.RestrictToBrowserContext(browser()->profile()); event_router()->GattServiceAdded( mock_adapter_, device0_.get(), service0_.get()); @@ -770,7 +772,7 @@ IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, WriteCharacteristicValue) { IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, GetDescriptors) { ResultCatcher catcher; - catcher.RestrictToProfile(browser()->profile()); + catcher.RestrictToBrowserContext(browser()->profile()); std::vector<BluetoothGattDescriptor*> descriptors; descriptors.push_back(desc0_.get()); @@ -811,7 +813,7 @@ IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, GetDescriptors) { IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, GetDescriptor) { ResultCatcher catcher; - catcher.RestrictToProfile(browser()->profile()); + catcher.RestrictToBrowserContext(browser()->profile()); event_router()->GattServiceAdded( mock_adapter_, device0_.get(), service0_.get()); @@ -856,7 +858,7 @@ IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, GetDescriptor) { IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, GetRemovedDescriptor) { ResultCatcher catcher; - catcher.RestrictToProfile(browser()->profile()); + catcher.RestrictToBrowserContext(browser()->profile()); EXPECT_CALL(*mock_adapter_, GetDevice(_)) .Times(1) @@ -907,7 +909,7 @@ IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, GetRemovedDescriptor) { IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, DescriptorValueChanged) { ResultCatcher catcher; - catcher.RestrictToProfile(browser()->profile()); + catcher.RestrictToBrowserContext(browser()->profile()); event_router()->GattServiceAdded( mock_adapter_, device0_.get(), service0_.get()); @@ -940,7 +942,7 @@ IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, DescriptorValueChanged) { IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, ReadDescriptorValue) { ResultCatcher catcher; - catcher.RestrictToProfile(browser()->profile()); + catcher.RestrictToBrowserContext(browser()->profile()); event_router()->GattServiceAdded( mock_adapter_, device0_.get(), service0_.get()); @@ -986,7 +988,7 @@ IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, ReadDescriptorValue) { IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, WriteDescriptorValue) { ResultCatcher catcher; - catcher.RestrictToProfile(browser()->profile()); + catcher.RestrictToBrowserContext(browser()->profile()); event_router()->GattServiceAdded( mock_adapter_, device0_.get(), service0_.get()); @@ -1034,7 +1036,7 @@ IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, WriteDescriptorValue) { IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, PermissionDenied) { ResultCatcher catcher; - catcher.RestrictToProfile(browser()->profile()); + catcher.RestrictToBrowserContext(browser()->profile()); ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII( "bluetooth_low_energy/permission_denied"))); @@ -1043,7 +1045,7 @@ IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, PermissionDenied) { IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, UuidPermissionMethods) { ResultCatcher catcher; - catcher.RestrictToProfile(browser()->profile()); + catcher.RestrictToBrowserContext(browser()->profile()); event_router()->GattServiceAdded( mock_adapter_, device0_.get(), service0_.get()); @@ -1075,7 +1077,7 @@ IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, UuidPermissionMethods) { IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, UuidPermissionEvents) { ResultCatcher catcher; - catcher.RestrictToProfile(browser()->profile()); + catcher.RestrictToBrowserContext(browser()->profile()); ExtensionTestMessageListener listener("ready", true); ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII( @@ -1106,8 +1108,7 @@ IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, UuidPermissionEvents) { IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, GattConnection) { ResultCatcher catcher; - catcher.RestrictToProfile(browser()->profile()); - + catcher.RestrictToBrowserContext(browser()->profile()); EXPECT_CALL(*mock_adapter_, GetDevice(_)) .WillRepeatedly(Return(static_cast<BluetoothDevice*>(NULL))); @@ -1137,8 +1138,7 @@ IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, GattConnection) { IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, ReconnectAfterDisconnected) { ResultCatcher catcher; - catcher.RestrictToProfile(browser()->profile()); - + catcher.RestrictToBrowserContext(browser()->profile()); EXPECT_CALL(*mock_adapter_, GetDevice(kTestLeDeviceAddress0)) .WillRepeatedly(Return(device0_.get())); @@ -1167,8 +1167,7 @@ IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, ReconnectAfterDisconnected) { IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, ConnectInProgress) { ResultCatcher catcher; - catcher.RestrictToProfile(browser()->profile()); - + catcher.RestrictToBrowserContext(browser()->profile()); EXPECT_CALL(*mock_adapter_, GetDevice(kTestLeDeviceAddress0)) .WillRepeatedly(Return(device0_.get())); @@ -1205,7 +1204,7 @@ IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, ConnectInProgress) { IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTest, StartStopNotifications) { ResultCatcher catcher; - catcher.RestrictToProfile(browser()->profile()); + catcher.RestrictToBrowserContext(browser()->profile()); event_router()->GattServiceAdded( mock_adapter_, device0_.get(), service0_.get()); diff --git a/extensions/browser/api/bluetooth_socket/bluetooth_socket_apitest.cc b/extensions/browser/api/bluetooth_socket/bluetooth_socket_apitest.cc index 4fefdc5..bb5d8d0 100644 --- a/extensions/browser/api/bluetooth_socket/bluetooth_socket_apitest.cc +++ b/extensions/browser/api/bluetooth_socket/bluetooth_socket_apitest.cc @@ -18,6 +18,7 @@ #include "device/bluetooth/test/mock_bluetooth_device.h" #include "device/bluetooth/test/mock_bluetooth_socket.h" #include "extensions/browser/api/bluetooth_socket/bluetooth_socket_api.h" +#include "extensions/test/result_catcher.h" #include "testing/gmock/include/gmock/gmock.h" using device::BluetoothAdapter; @@ -29,6 +30,7 @@ using device::MockBluetoothAdapter; using device::MockBluetoothDevice; using device::MockBluetoothSocket; using extensions::Extension; +using extensions::ResultCatcher; namespace utils = extension_function_test_utils; namespace api = extensions::core_api; @@ -100,7 +102,7 @@ ACTION_TEMPLATE(InvokeCallbackArgument, IN_PROC_BROWSER_TEST_F(BluetoothSocketApiTest, Connect) { ResultCatcher catcher; - catcher.RestrictToProfile(browser()->profile()); + catcher.RestrictToBrowserContext(browser()->profile()); // Return the right mock device object for the address used by the test, // return NULL for the "Device not found" test. @@ -145,7 +147,7 @@ IN_PROC_BROWSER_TEST_F(BluetoothSocketApiTest, Connect) { #endif IN_PROC_BROWSER_TEST_F(BluetoothSocketApiTest, MAYBE_Listen) { ResultCatcher catcher; - catcher.RestrictToProfile(browser()->profile()); + catcher.RestrictToBrowserContext(browser()->profile()); // Return a mock socket object as a successful result to the create service // call. @@ -207,7 +209,7 @@ IN_PROC_BROWSER_TEST_F(BluetoothSocketApiTest, MAYBE_Listen) { IN_PROC_BROWSER_TEST_F(BluetoothSocketApiTest, PermissionDenied) { ResultCatcher catcher; - catcher.RestrictToProfile(browser()->profile()); + catcher.RestrictToBrowserContext(browser()->profile()); // Run the test. scoped_refptr<const Extension> extension( diff --git a/extensions/browser/api/cast_channel/cast_channel_apitest.cc b/extensions/browser/api/cast_channel/cast_channel_apitest.cc index 322a547..289c71e 100644 --- a/extensions/browser/api/cast_channel/cast_channel_apitest.cc +++ b/extensions/browser/api/cast_channel/cast_channel_apitest.cc @@ -15,6 +15,7 @@ #include "extensions/browser/api/cast_channel/logger.h" #include "extensions/common/api/cast_channel.h" #include "extensions/common/switches.h" +#include "extensions/test/result_catcher.h" #include "net/base/capturing_net_log.h" #include "net/base/completion_callback.h" #include "net/base/net_errors.h" @@ -247,7 +248,7 @@ IN_PROC_BROWSER_TEST_F(CastChannelAPITest, MAYBE_TestOpenReceiveClose) { EXPECT_TRUE(RunExtensionSubtest("cast_channel/api", "test_open_receive_close.html")); - ResultCatcher catcher; + extensions::ResultCatcher catcher; CallOnMessage("some-message"); CallOnMessage("some-message"); EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); diff --git a/extensions/browser/api/runtime/runtime_apitest.cc b/extensions/browser/api/runtime/runtime_apitest.cc index 2f92756..764e22e 100644 --- a/extensions/browser/api/runtime/runtime_apitest.cc +++ b/extensions/browser/api/runtime/runtime_apitest.cc @@ -11,6 +11,7 @@ #include "content/public/browser/notification_service.h" #include "extensions/browser/api/runtime/runtime_api.h" #include "extensions/browser/extension_registry.h" +#include "extensions/test/result_catcher.h" #include "net/test/embedded_test_server/embedded_test_server.h" // Tests the privileged components of chrome.runtime. @@ -25,7 +26,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ChromeRuntimeUnprivileged) { LoadExtension(test_data_dir_.AppendASCII("runtime/content_script"))); // The content script runs on webpage.html. - ResultCatcher catcher; + extensions::ResultCatcher catcher; ui_test_utils::NavigateToURL(browser(), embedded_test_server()->GetURL("/webpage.html")); EXPECT_TRUE(catcher.GetNextResult()) << message_; diff --git a/extensions/browser/api/serial/serial_apitest.cc b/extensions/browser/api/serial/serial_apitest.cc index 22089c9c..db7617a 100644 --- a/extensions/browser/api/serial/serial_apitest.cc +++ b/extensions/browser/api/serial/serial_apitest.cc @@ -10,6 +10,7 @@ #include "extensions/browser/api/serial/serial_connection.h" #include "extensions/browser/extension_function.h" #include "extensions/common/api/serial.h" +#include "extensions/test/result_catcher.h" #include "testing/gmock/include/gmock/gmock.h" using testing::_; @@ -114,8 +115,8 @@ ExtensionFunction* FakeSerialConnectFunctionFactory() { // #define SIMULATE_SERIAL_PORTS (1) IN_PROC_BROWSER_TEST_F(SerialApiTest, SerialFakeHardware) { - ResultCatcher catcher; - catcher.RestrictToProfile(browser()->profile()); + extensions::ResultCatcher catcher; + catcher.RestrictToBrowserContext(browser()->profile()); #if SIMULATE_SERIAL_PORTS ASSERT_TRUE(extensions::ExtensionFunctionDispatcher::OverrideFunction( @@ -128,8 +129,8 @@ IN_PROC_BROWSER_TEST_F(SerialApiTest, SerialFakeHardware) { } IN_PROC_BROWSER_TEST_F(SerialApiTest, SerialRealHardware) { - ResultCatcher catcher; - catcher.RestrictToProfile(browser()->profile()); + extensions::ResultCatcher catcher; + catcher.RestrictToBrowserContext(browser()->profile()); ASSERT_TRUE(RunExtensionTest("serial/real_hardware")) << message_; } diff --git a/extensions/test/result_catcher.h b/extensions/test/result_catcher.h index 43ebc27..f389f85 100644 --- a/extensions/test/result_catcher.h +++ b/extensions/test/result_catcher.h @@ -23,7 +23,6 @@ namespace extensions { // GetNextResult() and message() if GetNextResult() return false. If there // are no results, this method will pump the UI message loop until one is // received. -// TODO(yoz): Replace the version in ExtensionApiTest with this. class ResultCatcher : public content::NotificationObserver { public: ResultCatcher(); |