| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <vector> | 5 #include <vector> |
| 6 | 6 |
| 7 #include "base/callback_list.h" | 7 #include "base/callback_list.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 ExtensionWebstorePrivateApiTest() | 106 ExtensionWebstorePrivateApiTest() |
| 107 : signin_manager_(NULL), | 107 : signin_manager_(NULL), |
| 108 token_service_(NULL) {} | 108 token_service_(NULL) {} |
| 109 virtual ~ExtensionWebstorePrivateApiTest() {} | 109 virtual ~ExtensionWebstorePrivateApiTest() {} |
| 110 | 110 |
| 111 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 111 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 112 ExtensionApiTest::SetUpCommandLine(command_line); | 112 ExtensionApiTest::SetUpCommandLine(command_line); |
| 113 command_line->AppendSwitchASCII( | 113 command_line->AppendSwitchASCII( |
| 114 switches::kAppsGalleryURL, | 114 switches::kAppsGalleryURL, |
| 115 "http://www.example.com/files/extensions/api_test"); | 115 "http://www.example.com/files/extensions/api_test"); |
| 116 command_line->AppendSwitchASCII( | |
| 117 switches::kAppsGalleryInstallAutoConfirmForTests, "accept"); | |
| 118 } | 116 } |
| 119 | 117 |
| 120 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | 118 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { |
| 121 ExtensionApiTest::SetUpInProcessBrowserTestFixture(); | 119 ExtensionApiTest::SetUpInProcessBrowserTestFixture(); |
| 122 | 120 |
| 123 // Start up the test server and get us ready for calling the install | 121 // Start up the test server and get us ready for calling the install |
| 124 // API functions. | 122 // API functions. |
| 125 host_resolver()->AddRule("www.example.com", "127.0.0.1"); | 123 host_resolver()->AddRule("www.example.com", "127.0.0.1"); |
| 126 ASSERT_TRUE(StartSpawnedTestServer()); | 124 ASSERT_TRUE(StartSpawnedTestServer()); |
| 127 ExtensionInstallUI::set_disable_failure_ui_for_tests(); | 125 ExtensionInstallUI::set_disable_failure_ui_for_tests(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 141 // observers and end up needing to unregister when the fake is substituted. | 139 // observers and end up needing to unregister when the fake is substituted. |
| 142 SigninManagerFactory::GetInstance()->SetTestingFactory( | 140 SigninManagerFactory::GetInstance()->SetTestingFactory( |
| 143 context, &FakeSigninManagerBase::Build); | 141 context, &FakeSigninManagerBase::Build); |
| 144 ProfileOAuth2TokenServiceFactory::GetInstance()->SetTestingFactory( | 142 ProfileOAuth2TokenServiceFactory::GetInstance()->SetTestingFactory( |
| 145 context, &BuildFakeProfileOAuth2TokenService); | 143 context, &BuildFakeProfileOAuth2TokenService); |
| 146 } | 144 } |
| 147 | 145 |
| 148 virtual void SetUpOnMainThread() OVERRIDE { | 146 virtual void SetUpOnMainThread() OVERRIDE { |
| 149 ExtensionApiTest::SetUpOnMainThread(); | 147 ExtensionApiTest::SetUpOnMainThread(); |
| 150 | 148 |
| 149 ExtensionInstallPrompt::g_auto_confirm_for_tests = |
| 150 ExtensionInstallPrompt::ACCEPT; |
| 151 |
| 151 // Grab references to the fake signin manager and token service. | 152 // Grab references to the fake signin manager and token service. |
| 152 signin_manager_ = | 153 signin_manager_ = |
| 153 static_cast<FakeSigninManagerForTesting*>( | 154 static_cast<FakeSigninManagerForTesting*>( |
| 154 SigninManagerFactory::GetInstance()->GetForProfile(profile())); | 155 SigninManagerFactory::GetInstance()->GetForProfile(profile())); |
| 155 ASSERT_TRUE(signin_manager_); | 156 ASSERT_TRUE(signin_manager_); |
| 156 token_service_ = | 157 token_service_ = |
| 157 static_cast<FakeProfileOAuth2TokenService*>( | 158 static_cast<FakeProfileOAuth2TokenService*>( |
| 158 ProfileOAuth2TokenServiceFactory::GetInstance()->GetForProfile( | 159 ProfileOAuth2TokenServiceFactory::GetInstance()->GetForProfile( |
| 159 profile())); | 160 profile())); |
| 160 ASSERT_TRUE(token_service_); | 161 ASSERT_TRUE(token_service_); |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 EXPECT_TRUE(base::DeleteFile(missing_directory, true)); | 293 EXPECT_TRUE(base::DeleteFile(missing_directory, true)); |
| 293 } | 294 } |
| 294 | 295 |
| 295 // Tests passing a localized name. | 296 // Tests passing a localized name. |
| 296 IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateApiTest, InstallLocalized) { | 297 IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateApiTest, InstallLocalized) { |
| 297 ASSERT_TRUE(RunInstallTest("localized.html", "localized_extension.crx")); | 298 ASSERT_TRUE(RunInstallTest("localized.html", "localized_extension.crx")); |
| 298 } | 299 } |
| 299 | 300 |
| 300 // Now test the case where the user cancels the confirmation dialog. | 301 // Now test the case where the user cancels the confirmation dialog. |
| 301 IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateApiTest, InstallCancelled) { | 302 IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateApiTest, InstallCancelled) { |
| 302 CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 303 ExtensionInstallPrompt::g_auto_confirm_for_tests = |
| 303 switches::kAppsGalleryInstallAutoConfirmForTests, "cancel"); | 304 ExtensionInstallPrompt::CANCEL; |
| 304 ASSERT_TRUE(RunInstallTest("cancelled.html", "extension.crx")); | 305 ASSERT_TRUE(RunInstallTest("cancelled.html", "extension.crx")); |
| 305 } | 306 } |
| 306 | 307 |
| 307 IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateApiTest, IncorrectManifest1) { | 308 IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateApiTest, IncorrectManifest1) { |
| 308 ASSERT_TRUE(RunInstallTest("incorrect_manifest1.html", "extension.crx")); | 309 ASSERT_TRUE(RunInstallTest("incorrect_manifest1.html", "extension.crx")); |
| 309 } | 310 } |
| 310 | 311 |
| 311 IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateApiTest, IncorrectManifest2) { | 312 IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateApiTest, IncorrectManifest2) { |
| 312 ASSERT_TRUE(RunInstallTest("incorrect_manifest2.html", "extension.crx")); | 313 ASSERT_TRUE(RunInstallTest("incorrect_manifest2.html", "extension.crx")); |
| 313 } | 314 } |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 613 } | 614 } |
| 614 | 615 |
| 615 // Run tests when the --enable-ephemeral-apps switch is enabled. | 616 // Run tests when the --enable-ephemeral-apps switch is enabled. |
| 616 IN_PROC_BROWSER_TEST_F(EphemeralAppWebstorePrivateApiTest, LaunchEphemeralApp) { | 617 IN_PROC_BROWSER_TEST_F(EphemeralAppWebstorePrivateApiTest, LaunchEphemeralApp) { |
| 617 CommandLine::ForCurrentProcess()->AppendSwitch( | 618 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 618 switches::kEnableEphemeralApps); | 619 switches::kEnableEphemeralApps); |
| 619 ASSERT_TRUE(RunInstallTest("webstore_launch_app.html", "app.crx")); | 620 ASSERT_TRUE(RunInstallTest("webstore_launch_app.html", "app.crx")); |
| 620 } | 621 } |
| 621 | 622 |
| 622 } // namespace extensions | 623 } // namespace extensions |
| OLD | NEW |