Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(615)

Side by Side Diff: chrome/browser/apps/app_browsertest.cc

Issue 757433004: Add SOURCE_TEST. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed remaining instances of SOURCE_BROWSER_TEST. Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/apps/app_browsertest_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "apps/launcher.h" 5 #include "apps/launcher.h"
6 #include "base/bind.h" 6 #include "base/bind.h"
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
9 #include "base/files/scoped_temp_dir.h" 9 #include "base/files/scoped_temp_dir.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 command_line->AppendArgPath(relative_test_doc); 505 command_line->AppendArgPath(relative_test_doc);
506 506
507 // Load the extension 507 // Load the extension
508 ResultCatcher catcher; 508 ResultCatcher catcher;
509 const Extension* extension = LoadExtension( 509 const Extension* extension = LoadExtension(
510 test_data_dir_.AppendASCII("platform_apps/launch_file")); 510 test_data_dir_.AppendASCII("platform_apps/launch_file"));
511 ASSERT_TRUE(extension); 511 ASSERT_TRUE(extension);
512 512
513 // Run the test 513 // Run the test
514 AppLaunchParams params(browser()->profile(), extension, LAUNCH_CONTAINER_NONE, 514 AppLaunchParams params(browser()->profile(), extension, LAUNCH_CONTAINER_NONE,
515 NEW_WINDOW, extensions::SOURCE_UNTRACKED); 515 NEW_WINDOW, extensions::SOURCE_TEST);
516 params.command_line = *CommandLine::ForCurrentProcess(); 516 params.command_line = *CommandLine::ForCurrentProcess();
517 params.current_directory = test_data_dir_; 517 params.current_directory = test_data_dir_;
518 OpenApplication(params); 518 OpenApplication(params);
519 519
520 if (!catcher.GetNextResult()) { 520 if (!catcher.GetNextResult()) {
521 message_ = catcher.message(); 521 message_ = catcher.message();
522 ASSERT_TRUE(0); 522 ASSERT_TRUE(0);
523 } 523 }
524 } 524 }
525 525
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
836 // Close the AppWindow, and ensure it is gone. 836 // Close the AppWindow, and ensure it is gone.
837 CloseAppWindow(window); 837 CloseAppWindow(window);
838 ASSERT_FALSE(GetFirstAppWindow()); 838 ASSERT_FALSE(GetFirstAppWindow());
839 839
840 // Relaunch the app and get a new AppWindow. 840 // Relaunch the app and get a new AppWindow.
841 content::WindowedNotificationObserver app_loaded_observer( 841 content::WindowedNotificationObserver app_loaded_observer(
842 content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, 842 content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME,
843 content::NotificationService::AllSources()); 843 content::NotificationService::AllSources());
844 OpenApplication(AppLaunchParams(browser()->profile(), extension, 844 OpenApplication(AppLaunchParams(browser()->profile(), extension,
845 LAUNCH_CONTAINER_NONE, NEW_WINDOW, 845 LAUNCH_CONTAINER_NONE, NEW_WINDOW,
846 extensions::SOURCE_UNTRACKED)); 846 extensions::SOURCE_TEST));
847 app_loaded_observer.Wait(); 847 app_loaded_observer.Wait();
848 window = GetFirstAppWindow(); 848 window = GetFirstAppWindow();
849 ASSERT_TRUE(window); 849 ASSERT_TRUE(window);
850 850
851 // DevTools should have reopened with the relaunch. 851 // DevTools should have reopened with the relaunch.
852 web_contents = window->web_contents(); 852 web_contents = window->web_contents();
853 ASSERT_TRUE(web_contents); 853 ASSERT_TRUE(web_contents);
854 ASSERT_TRUE(DevToolsAgentHost::HasFor(web_contents)); 854 ASSERT_TRUE(DevToolsAgentHost::HasFor(web_contents));
855 } 855 }
856 } 856 }
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
982 const Extension* extension = LoadExtensionAsComponent( 982 const Extension* extension = LoadExtensionAsComponent(
983 test_data_dir_.AppendASCII("platform_apps").AppendASCII("component")); 983 test_data_dir_.AppendASCII("platform_apps").AppendASCII("component"));
984 ASSERT_TRUE(extension); 984 ASSERT_TRUE(extension);
985 985
986 app_loaded_observer.Wait(); 986 app_loaded_observer.Wait();
987 ASSERT_TRUE(should_install.seen()); 987 ASSERT_TRUE(should_install.seen());
988 988
989 ExtensionTestMessageListener launched_listener("Launched", false); 989 ExtensionTestMessageListener launched_listener("Launched", false);
990 OpenApplication(AppLaunchParams(browser()->profile(), extension, 990 OpenApplication(AppLaunchParams(browser()->profile(), extension,
991 LAUNCH_CONTAINER_NONE, NEW_WINDOW, 991 LAUNCH_CONTAINER_NONE, NEW_WINDOW,
992 extensions::SOURCE_UNTRACKED)); 992 extensions::SOURCE_TEST));
993 993
994 ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); 994 ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
995 } 995 }
996 996
997 // Component App Test 2 of 3: ensure an installed component app can be launched 997 // Component App Test 2 of 3: ensure an installed component app can be launched
998 // on a subsequent browser start, without requiring any install/upgrade logic 998 // on a subsequent browser start, without requiring any install/upgrade logic
999 // to be run, then perform setup for step 3. 999 // to be run, then perform setup for step 3.
1000 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, 1000 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest,
1001 PRE_ComponentAppBackgroundPage) { 1001 PRE_ComponentAppBackgroundPage) {
1002 1002
1003 // Since the component app is now installed, re-adding it in the same profile 1003 // Since the component app is now installed, re-adding it in the same profile
1004 // should not cause it to be re-installed. Instead, we wait for the OnLaunched 1004 // should not cause it to be re-installed. Instead, we wait for the OnLaunched
1005 // in a different observer (which would timeout if not the app was not 1005 // in a different observer (which would timeout if not the app was not
1006 // previously installed properly) and then check this observer to make sure it 1006 // previously installed properly) and then check this observer to make sure it
1007 // never saw the NOTIFICATION_EXTENSION_WILL_BE_INSTALLED_DEPRECATED event. 1007 // never saw the NOTIFICATION_EXTENSION_WILL_BE_INSTALLED_DEPRECATED event.
1008 CheckExtensionInstalledObserver should_not_install; 1008 CheckExtensionInstalledObserver should_not_install;
1009 const Extension* extension = LoadExtensionAsComponent( 1009 const Extension* extension = LoadExtensionAsComponent(
1010 test_data_dir_.AppendASCII("platform_apps").AppendASCII("component")); 1010 test_data_dir_.AppendASCII("platform_apps").AppendASCII("component"));
1011 ASSERT_TRUE(extension); 1011 ASSERT_TRUE(extension);
1012 1012
1013 ExtensionTestMessageListener launched_listener("Launched", false); 1013 ExtensionTestMessageListener launched_listener("Launched", false);
1014 OpenApplication(AppLaunchParams(browser()->profile(), extension, 1014 OpenApplication(AppLaunchParams(browser()->profile(), extension,
1015 LAUNCH_CONTAINER_NONE, NEW_WINDOW, 1015 LAUNCH_CONTAINER_NONE, NEW_WINDOW,
1016 extensions::SOURCE_UNTRACKED)); 1016 extensions::SOURCE_TEST));
1017 1017
1018 ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); 1018 ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
1019 ASSERT_FALSE(should_not_install.seen()); 1019 ASSERT_FALSE(should_not_install.seen());
1020 1020
1021 // Simulate a "downgrade" from version 2 in the test manifest.json to 1. 1021 // Simulate a "downgrade" from version 2 in the test manifest.json to 1.
1022 ExtensionPrefs* extension_prefs = ExtensionPrefs::Get(browser()->profile()); 1022 ExtensionPrefs* extension_prefs = ExtensionPrefs::Get(browser()->profile());
1023 1023
1024 // Clear the registered events to ensure they are updated. 1024 // Clear the registered events to ensure they are updated.
1025 extensions::EventRouter::Get(browser()->profile()) 1025 extensions::EventRouter::Get(browser()->profile())
1026 ->SetRegisteredEvents(extension->id(), std::set<std::string>()); 1026 ->SetRegisteredEvents(extension->id(), std::set<std::string>());
(...skipping 17 matching lines...) Expand all
1044 1044
1045 const Extension* extension = LoadExtensionAsComponent( 1045 const Extension* extension = LoadExtensionAsComponent(
1046 test_data_dir_.AppendASCII("platform_apps").AppendASCII("component")); 1046 test_data_dir_.AppendASCII("platform_apps").AppendASCII("component"));
1047 ASSERT_TRUE(extension); 1047 ASSERT_TRUE(extension);
1048 app_loaded_observer.Wait(); 1048 app_loaded_observer.Wait();
1049 ASSERT_TRUE(should_install.seen()); 1049 ASSERT_TRUE(should_install.seen());
1050 1050
1051 ExtensionTestMessageListener launched_listener("Launched", false); 1051 ExtensionTestMessageListener launched_listener("Launched", false);
1052 OpenApplication(AppLaunchParams(browser()->profile(), extension, 1052 OpenApplication(AppLaunchParams(browser()->profile(), extension,
1053 LAUNCH_CONTAINER_NONE, NEW_WINDOW, 1053 LAUNCH_CONTAINER_NONE, NEW_WINDOW,
1054 extensions::SOURCE_UNTRACKED)); 1054 extensions::SOURCE_TEST));
1055 1055
1056 ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); 1056 ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
1057 } 1057 }
1058 1058
1059 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, 1059 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest,
1060 ComponentExtensionRuntimeReload) { 1060 ComponentExtensionRuntimeReload) {
1061 // Ensure that we wait until the background page is run (to register the 1061 // Ensure that we wait until the background page is run (to register the
1062 // OnLaunched listener) before trying to open the application. This is similar 1062 // OnLaunched listener) before trying to open the application. This is similar
1063 // to LoadAndLaunchPlatformApp, but we want to load as a component extension. 1063 // to LoadAndLaunchPlatformApp, but we want to load as a component extension.
1064 content::WindowedNotificationObserver app_loaded_observer( 1064 content::WindowedNotificationObserver app_loaded_observer(
1065 content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, 1065 content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME,
1066 content::NotificationService::AllSources()); 1066 content::NotificationService::AllSources());
1067 1067
1068 const Extension* extension = LoadExtensionAsComponent( 1068 const Extension* extension = LoadExtensionAsComponent(
1069 test_data_dir_.AppendASCII("platform_apps").AppendASCII("component")); 1069 test_data_dir_.AppendASCII("platform_apps").AppendASCII("component"));
1070 ASSERT_TRUE(extension); 1070 ASSERT_TRUE(extension);
1071 1071
1072 app_loaded_observer.Wait(); 1072 app_loaded_observer.Wait();
1073 1073
1074 { 1074 {
1075 ExtensionTestMessageListener launched_listener("Launched", false); 1075 ExtensionTestMessageListener launched_listener("Launched", false);
1076 OpenApplication(AppLaunchParams(browser()->profile(), extension, 1076 OpenApplication(AppLaunchParams(browser()->profile(), extension,
1077 LAUNCH_CONTAINER_NONE, NEW_WINDOW, 1077 LAUNCH_CONTAINER_NONE, NEW_WINDOW,
1078 extensions::SOURCE_UNTRACKED)); 1078 extensions::SOURCE_TEST));
1079 ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); 1079 ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
1080 } 1080 }
1081 1081
1082 { 1082 {
1083 ExtensionTestMessageListener launched_listener("Launched", false); 1083 ExtensionTestMessageListener launched_listener("Launched", false);
1084 ASSERT_TRUE(ExecuteScriptInBackgroundPageNoWait( 1084 ASSERT_TRUE(ExecuteScriptInBackgroundPageNoWait(
1085 extension->id(), 1085 extension->id(),
1086 // NoWait actually waits for a domAutomationController.send() which is 1086 // NoWait actually waits for a domAutomationController.send() which is
1087 // implicitly append to the script. Since reload() restarts the 1087 // implicitly append to the script. Since reload() restarts the
1088 // extension, the send after reload may not get executed. To get around 1088 // extension, the send after reload may not get executed. To get around
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
1220 content::RunAllPendingInMessageLoop(); 1220 content::RunAllPendingInMessageLoop();
1221 } 1221 }
1222 1222
1223 // Listen for new app windows so we see the file manager app launch itself. 1223 // Listen for new app windows so we see the file manager app launch itself.
1224 AppWindowRegistry* registry = AppWindowRegistry::Get(incognito_profile); 1224 AppWindowRegistry* registry = AppWindowRegistry::Get(incognito_profile);
1225 ASSERT_TRUE(registry != NULL); 1225 ASSERT_TRUE(registry != NULL);
1226 registry->AddObserver(this); 1226 registry->AddObserver(this);
1227 1227
1228 OpenApplication(AppLaunchParams(incognito_profile, file_manager, CURRENT_TAB, 1228 OpenApplication(AppLaunchParams(incognito_profile, file_manager, CURRENT_TAB,
1229 chrome::HOST_DESKTOP_TYPE_NATIVE, 1229 chrome::HOST_DESKTOP_TYPE_NATIVE,
1230 extensions::SOURCE_UNTRACKED)); 1230 extensions::SOURCE_TEST));
1231 1231
1232 while (!ContainsKey(opener_app_ids_, file_manager->id())) { 1232 while (!ContainsKey(opener_app_ids_, file_manager->id())) {
1233 content::RunAllPendingInMessageLoop(); 1233 content::RunAllPendingInMessageLoop();
1234 } 1234 }
1235 } 1235 }
1236 1236
1237 class RestartDeviceTest : public PlatformAppBrowserTest { 1237 class RestartDeviceTest : public PlatformAppBrowserTest {
1238 public: 1238 public:
1239 RestartDeviceTest() 1239 RestartDeviceTest()
1240 : power_manager_client_(NULL), 1240 : power_manager_client_(NULL),
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
1331 LoadAndLaunchPlatformApp("reinstall_data_cleanup", "Launched"); 1331 LoadAndLaunchPlatformApp("reinstall_data_cleanup", "Launched");
1332 ASSERT_TRUE(extension); 1332 ASSERT_TRUE(extension);
1333 ASSERT_EQ(extension_id, extension->id()); 1333 ASSERT_EQ(extension_id, extension->id());
1334 1334
1335 ResultCatcher result_catcher; 1335 ResultCatcher result_catcher;
1336 EXPECT_TRUE(result_catcher.GetNextResult()); 1336 EXPECT_TRUE(result_catcher.GetNextResult());
1337 } 1337 }
1338 } 1338 }
1339 1339
1340 } // namespace extensions 1340 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/apps/app_browsertest_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698