OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "base/message_loop/message_loop_proxy.h" | 5 #include "base/message_loop/message_loop_proxy.h" |
6 #include "chrome/browser/apps/ephemeral_app_launcher.h" | 6 #include "chrome/browser/apps/ephemeral_app_launcher.h" |
7 #include "chrome/browser/apps/ephemeral_app_service.h" | 7 #include "chrome/browser/apps/ephemeral_app_service.h" |
8 #include "chrome/browser/extensions/extension_install_checker.h" | 8 #include "chrome/browser/extensions/extension_install_checker.h" |
9 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
10 #include "chrome/browser/extensions/install_tracker.h" | 10 #include "chrome/browser/extensions/install_tracker.h" |
11 #include "chrome/browser/extensions/test_blacklist.h" | 11 #include "chrome/browser/extensions/test_blacklist.h" |
12 #include "chrome/browser/extensions/webstore_installer_test.h" | 12 #include "chrome/browser/extensions/webstore_installer_test.h" |
13 #include "chrome/browser/ui/browser_finder.h" | 13 #include "chrome/browser/ui/browser_finder.h" |
14 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 14 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
15 #include "chrome/common/chrome_switches.h" | 15 #include "chrome/common/chrome_switches.h" |
16 #include "content/public/browser/web_contents.h" | 16 #include "content/public/browser/web_contents.h" |
17 #include "content/public/test/test_utils.h" | 17 #include "content/public/test/test_utils.h" |
18 #include "extensions/browser/extension_prefs.h" | 18 #include "extensions/browser/extension_prefs.h" |
19 #include "extensions/browser/extension_registry.h" | 19 #include "extensions/browser/extension_registry.h" |
20 #include "extensions/browser/extension_system.h" | 20 #include "extensions/browser/extension_system.h" |
21 #include "extensions/browser/extension_util.h" | 21 #include "extensions/browser/extension_util.h" |
22 #include "extensions/browser/management_policy.h" | 22 #include "extensions/browser/management_policy.h" |
23 #include "extensions/browser/process_manager.h" | 23 #include "extensions/browser/process_manager.h" |
24 #include "extensions/test/extension_test_message_listener.h" | 24 #include "extensions/test/extension_test_message_listener.h" |
25 #include "ui/app_list/app_list_switches.h" | |
26 | 25 |
27 using extensions::Extension; | 26 using extensions::Extension; |
28 using extensions::ExtensionPrefs; | 27 using extensions::ExtensionPrefs; |
29 using extensions::ExtensionRegistry; | 28 using extensions::ExtensionRegistry; |
30 using extensions::ExtensionSystem; | 29 using extensions::ExtensionSystem; |
31 using extensions::InstallTracker; | 30 using extensions::InstallTracker; |
32 namespace webstore_install = extensions::webstore_install; | 31 namespace webstore_install = extensions::webstore_install; |
33 | 32 |
34 namespace { | 33 namespace { |
35 | 34 |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 kNonAppDomain) {} | 195 kNonAppDomain) {} |
197 | 196 |
198 void SetUpCommandLine(base::CommandLine* command_line) override { | 197 void SetUpCommandLine(base::CommandLine* command_line) override { |
199 WebstoreInstallerTest::SetUpCommandLine(command_line); | 198 WebstoreInstallerTest::SetUpCommandLine(command_line); |
200 | 199 |
201 // Make event pages get suspended immediately. | 200 // Make event pages get suspended immediately. |
202 extensions::ProcessManager::SetEventPageIdleTimeForTesting(1); | 201 extensions::ProcessManager::SetEventPageIdleTimeForTesting(1); |
203 extensions::ProcessManager::SetEventPageSuspendingTimeForTesting(1); | 202 extensions::ProcessManager::SetEventPageSuspendingTimeForTesting(1); |
204 | 203 |
205 // Enable ephemeral apps flag. | 204 // Enable ephemeral apps flag. |
206 command_line->AppendSwitch(app_list::switches::kEnableExperimentalAppList); | 205 command_line->AppendSwitch(switches::kEnableEphemeralAppsInWebstore); |
207 } | 206 } |
208 | 207 |
209 void SetUpOnMainThread() override { | 208 void SetUpOnMainThread() override { |
210 WebstoreInstallerTest::SetUpOnMainThread(); | 209 WebstoreInstallerTest::SetUpOnMainThread(); |
211 | 210 |
212 // Disable ephemeral apps immediately after they stop running in tests. | 211 // Disable ephemeral apps immediately after they stop running in tests. |
213 EphemeralAppService::Get(profile())->set_disable_delay_for_test(0); | 212 EphemeralAppService::Get(profile())->set_disable_delay_for_test(0); |
214 } | 213 } |
215 | 214 |
216 base::FilePath GetTestPath(const char* test_name) { | 215 base::FilePath GetTestPath(const char* test_name) { |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 public: | 305 public: |
307 void SetUpCommandLine(base::CommandLine* command_line) override { | 306 void SetUpCommandLine(base::CommandLine* command_line) override { |
308 // Skip EphemeralAppLauncherTest as it enables the feature. | 307 // Skip EphemeralAppLauncherTest as it enables the feature. |
309 WebstoreInstallerTest::SetUpCommandLine(command_line); | 308 WebstoreInstallerTest::SetUpCommandLine(command_line); |
310 } | 309 } |
311 }; | 310 }; |
312 | 311 |
313 // Verifies that an ephemeral app will not be installed and launched if the | 312 // Verifies that an ephemeral app will not be installed and launched if the |
314 // feature is disabled. | 313 // feature is disabled. |
315 IN_PROC_BROWSER_TEST_F(EphemeralAppLauncherTestDisabled, FeatureDisabled) { | 314 IN_PROC_BROWSER_TEST_F(EphemeralAppLauncherTestDisabled, FeatureDisabled) { |
316 base::CommandLine::ForCurrentProcess()->AppendSwitch( | |
317 app_list::switches::kDisableExperimentalAppList); | |
318 RunLaunchTest( | 315 RunLaunchTest( |
319 kDefaultAppCrxFilename, webstore_install::LAUNCH_FEATURE_DISABLED, false); | 316 kDefaultAppCrxFilename, webstore_install::LAUNCH_FEATURE_DISABLED, false); |
320 EXPECT_FALSE(GetInstalledExtension(kDefaultAppId)); | 317 EXPECT_FALSE(GetInstalledExtension(kDefaultAppId)); |
321 } | 318 } |
322 | 319 |
323 // Verifies that an app with no permission warnings will be installed | 320 // Verifies that an app with no permission warnings will be installed |
324 // ephemerally and launched without prompting the user. | 321 // ephemerally and launched without prompting the user. |
325 IN_PROC_BROWSER_TEST_F(EphemeralAppLauncherTest, | 322 IN_PROC_BROWSER_TEST_F(EphemeralAppLauncherTest, |
326 LaunchAppWithNoPermissionWarnings) { | 323 LaunchAppWithNoPermissionWarnings) { |
327 content::WindowedNotificationObserver unloaded_signal( | 324 content::WindowedNotificationObserver unloaded_signal( |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
562 } | 559 } |
563 | 560 |
564 // Verifies that a launch will fail if a duplicate launch is in progress. | 561 // Verifies that a launch will fail if a duplicate launch is in progress. |
565 IN_PROC_BROWSER_TEST_F(EphemeralAppLauncherTest, DuplicateLaunchInProgress) { | 562 IN_PROC_BROWSER_TEST_F(EphemeralAppLauncherTest, DuplicateLaunchInProgress) { |
566 extensions::ActiveInstallData install_data(kDefaultAppId); | 563 extensions::ActiveInstallData install_data(kDefaultAppId); |
567 install_data.is_ephemeral = true; | 564 install_data.is_ephemeral = true; |
568 InstallTracker::Get(profile())->AddActiveInstall(install_data); | 565 InstallTracker::Get(profile())->AddActiveInstall(install_data); |
569 | 566 |
570 RunLaunchTest(kDefaultAppId, webstore_install::LAUNCH_IN_PROGRESS, false); | 567 RunLaunchTest(kDefaultAppId, webstore_install::LAUNCH_IN_PROGRESS, false); |
571 } | 568 } |
OLD | NEW |