OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/stringprintf.h" | 5 #include "base/stringprintf.h" |
6 #include "chrome/browser/extensions/extension_apitest.h" | 6 #include "chrome/browser/extensions/extension_apitest.h" |
| 7 #include "chrome/browser/extensions/extension_install_dialog.h" |
7 #include "chrome/browser/extensions/extension_install_ui.h" | 8 #include "chrome/browser/extensions/extension_install_ui.h" |
8 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
9 #include "chrome/browser/extensions/extension_webstore_private_api.h" | 10 #include "chrome/browser/extensions/extension_webstore_private_api.h" |
10 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
11 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
12 #include "chrome/common/chrome_notification_types.h" | 13 #include "chrome/common/chrome_notification_types.h" |
13 #include "chrome/common/chrome_switches.h" | 14 #include "chrome/common/chrome_switches.h" |
14 #include "chrome/test/base/ui_test_utils.h" | 15 #include "chrome/test/base/ui_test_utils.h" |
15 #include "content/common/notification_observer.h" | 16 #include "content/common/notification_observer.h" |
16 #include "content/common/notification_registrar.h" | 17 #include "content/common/notification_registrar.h" |
17 #include "content/common/notification_service.h" | 18 #include "content/common/notification_service.h" |
18 #include "net/base/mock_host_resolver.h" | 19 #include "net/base/mock_host_resolver.h" |
19 | 20 |
20 // A base class for tests below. | 21 // A base class for tests below. |
21 class ExtensionWebstorePrivateApiTest : public ExtensionApiTest { | 22 class ExtensionWebstorePrivateApiTest : public ExtensionApiTest { |
22 public: | 23 public: |
23 void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 24 void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
24 ExtensionApiTest::SetUpCommandLine(command_line); | 25 ExtensionApiTest::SetUpCommandLine(command_line); |
25 command_line->AppendSwitchASCII(switches::kAppsGalleryURL, | 26 command_line->AppendSwitchASCII(switches::kAppsGalleryURL, |
26 "http://www.example.com"); | 27 "http://www.example.com"); |
27 } | 28 } |
28 | 29 |
29 void SetUpInProcessBrowserTestFixture() OVERRIDE { | 30 void SetUpInProcessBrowserTestFixture() OVERRIDE { |
30 // Start up the test server and get us ready for calling the install | 31 // Start up the test server and get us ready for calling the install |
31 // API functions. | 32 // API functions. |
32 host_resolver()->AddRule("www.example.com", "127.0.0.1"); | 33 host_resolver()->AddRule("www.example.com", "127.0.0.1"); |
33 ASSERT_TRUE(test_server()->Start()); | 34 ASSERT_TRUE(test_server()->Start()); |
34 BeginInstallWithManifestFunction::SetIgnoreUserGestureForTests(true); | 35 BeginInstallWithManifestFunction::SetIgnoreUserGestureForTests(true); |
35 BeginInstallWithManifestFunction::SetAutoConfirmForTests(true); | 36 SetExtensionInstallDialogForManifestAutoConfirmForTests(true); |
36 ExtensionInstallUI::DisableFailureUIForTests(); | 37 ExtensionInstallUI::DisableFailureUIForTests(); |
37 } | 38 } |
38 | 39 |
39 protected: | 40 protected: |
40 // Returns a test server URL, but with host 'www.example.com' so it matches | 41 // Returns a test server URL, but with host 'www.example.com' so it matches |
41 // the web store app's extent that we set up via command line flags. | 42 // the web store app's extent that we set up via command line flags. |
42 GURL GetTestServerURL(const std::string& path) { | 43 GURL GetTestServerURL(const std::string& path) { |
43 GURL url = test_server()->GetURL( | 44 GURL url = test_server()->GetURL( |
44 std::string("files/extensions/api_test/webstore_private/") + path); | 45 std::string("files/extensions/api_test/webstore_private/") + path); |
45 | 46 |
(...skipping 27 matching lines...) Expand all Loading... |
73 ASSERT_TRUE(RunInstallTest("accepted.html", "extension.crx")); | 74 ASSERT_TRUE(RunInstallTest("accepted.html", "extension.crx")); |
74 } | 75 } |
75 | 76 |
76 // Tests passing a localized name. | 77 // Tests passing a localized name. |
77 IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateApiTest, InstallLocalized) { | 78 IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateApiTest, InstallLocalized) { |
78 ASSERT_TRUE(RunInstallTest("localized.html", "localized_extension.crx")); | 79 ASSERT_TRUE(RunInstallTest("localized.html", "localized_extension.crx")); |
79 } | 80 } |
80 | 81 |
81 // Now test the case where the user cancels the confirmation dialog. | 82 // Now test the case where the user cancels the confirmation dialog. |
82 IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateApiTest, InstallCancelled) { | 83 IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateApiTest, InstallCancelled) { |
83 BeginInstallWithManifestFunction::SetAutoConfirmForTests(false); | 84 SetExtensionInstallDialogForManifestAutoConfirmForTests(false); |
84 ASSERT_TRUE(RunInstallTest("cancelled.html", "extension.crx")); | 85 ASSERT_TRUE(RunInstallTest("cancelled.html", "extension.crx")); |
85 } | 86 } |
86 | 87 |
87 IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateApiTest, InstallNoGesture) { | 88 IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateApiTest, InstallNoGesture) { |
88 BeginInstallFunction::SetIgnoreUserGestureForTests(false); | 89 BeginInstallFunction::SetIgnoreUserGestureForTests(false); |
89 ASSERT_TRUE(RunInstallTest("no_user_gesture.html", "extension.crx")); | 90 ASSERT_TRUE(RunInstallTest("no_user_gesture.html", "extension.crx")); |
90 } | 91 } |
91 | 92 |
92 IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateApiTest, | 93 IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateApiTest, |
93 IncorrectManifest1) { | 94 IncorrectManifest1) { |
(...skipping 18 matching lines...) Expand all Loading... |
112 IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateApiTest, | 113 IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateApiTest, |
113 AppInstallBubble) { | 114 AppInstallBubble) { |
114 ASSERT_TRUE(RunInstallTest("app_install_bubble.html", "app.crx")); | 115 ASSERT_TRUE(RunInstallTest("app_install_bubble.html", "app.crx")); |
115 } | 116 } |
116 | 117 |
117 // Tests using the iconUrl parameter to the install function. | 118 // Tests using the iconUrl parameter to the install function. |
118 IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateApiTest, | 119 IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateApiTest, |
119 IconUrl) { | 120 IconUrl) { |
120 ASSERT_TRUE(RunInstallTest("icon_url.html", "extension.crx")); | 121 ASSERT_TRUE(RunInstallTest("icon_url.html", "extension.crx")); |
121 } | 122 } |
OLD | NEW |