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 <vector> |
| 6 |
| 7 #include "base/file_path.h" |
| 8 #include "base/file_util.h" |
5 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
6 #include "chrome/browser/extensions/extension_apitest.h" | 10 #include "chrome/browser/extensions/extension_apitest.h" |
7 #include "chrome/browser/extensions/extension_install_dialog.h" | 11 #include "chrome/browser/extensions/extension_install_dialog.h" |
8 #include "chrome/browser/extensions/extension_install_ui.h" | 12 #include "chrome/browser/extensions/extension_install_ui.h" |
9 #include "chrome/browser/extensions/extension_service.h" | 13 #include "chrome/browser/extensions/extension_service.h" |
10 #include "chrome/browser/extensions/extension_webstore_private_api.h" | 14 #include "chrome/browser/extensions/extension_webstore_private_api.h" |
11 #include "chrome/browser/extensions/webstore_installer.h" | 15 #include "chrome/browser/extensions/webstore_installer.h" |
12 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/browser/ui/browser.h" | 17 #include "chrome/browser/ui/browser.h" |
14 #include "chrome/common/chrome_notification_types.h" | 18 #include "chrome/common/chrome_notification_types.h" |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 | 122 |
119 GURL page_url = GetTestServerURL(page); | 123 GURL page_url = GetTestServerURL(page); |
120 return RunPageTest(page_url.spec()); | 124 return RunPageTest(page_url.spec()); |
121 } | 125 } |
122 | 126 |
123 ExtensionService* service() { | 127 ExtensionService* service() { |
124 return browser()->profile()->GetExtensionService(); | 128 return browser()->profile()->GetExtensionService(); |
125 } | 129 } |
126 }; | 130 }; |
127 | 131 |
| 132 class ExtensionWebstorePrivateBundleTest |
| 133 : public ExtensionWebstorePrivateApiTest { |
| 134 public: |
| 135 void SetUpInProcessBrowserTestFixture() OVERRIDE { |
| 136 ExtensionWebstorePrivateApiTest::SetUpInProcessBrowserTestFixture(); |
| 137 |
| 138 // The test server needs to have already started, so setup the switch here |
| 139 // rather than in SetUpCommandLine. |
| 140 CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
| 141 switches::kAppsGalleryDownloadURL, |
| 142 GetTestServerURL("bundle/%s.crx").spec()); |
| 143 |
| 144 PackCRX("begfmnajjkbjdgmffnjaojchoncnmngg"); |
| 145 PackCRX("bmfoocgfinpmkmlbjhcbofejhkhlbchk"); |
| 146 PackCRX("mpneghmdnmaolkljkipbhaienajcflfe"); |
| 147 } |
| 148 |
| 149 void TearDownInProcessBrowserTestFixture() OVERRIDE { |
| 150 ExtensionWebstorePrivateApiTest::TearDownInProcessBrowserTestFixture(); |
| 151 for (size_t i = 0; i < test_crx_.size(); ++i) |
| 152 ASSERT_TRUE(file_util::Delete(test_crx_[i], false)); |
| 153 } |
| 154 |
| 155 private: |
| 156 void PackCRX(const std::string& id) { |
| 157 FilePath data_path = test_data_dir_.AppendASCII("webstore_private/bundle"); |
| 158 FilePath dir_path = data_path.AppendASCII(id); |
| 159 FilePath pem_path = data_path.AppendASCII(id + ".pem"); |
| 160 FilePath crx_path = data_path.AppendASCII(id + ".crx"); |
| 161 FilePath destination = PackExtensionWithOptions( |
| 162 dir_path, crx_path, pem_path, FilePath()); |
| 163 |
| 164 ASSERT_FALSE(destination.empty()); |
| 165 ASSERT_EQ(destination, crx_path); |
| 166 |
| 167 test_crx_.push_back(destination); |
| 168 } |
| 169 |
| 170 std::vector<FilePath> test_crx_; |
| 171 }; |
| 172 |
128 // Test cases where the user accepts the install confirmation dialog. | 173 // Test cases where the user accepts the install confirmation dialog. |
129 IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateApiTest, InstallAccepted) { | 174 IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateApiTest, InstallAccepted) { |
130 ASSERT_TRUE(RunInstallTest("accepted.html", "extension.crx")); | 175 ASSERT_TRUE(RunInstallTest("accepted.html", "extension.crx")); |
131 } | 176 } |
132 | 177 |
133 // Tests passing a localized name. | 178 // Tests passing a localized name. |
134 IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateApiTest, InstallLocalized) { | 179 IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateApiTest, InstallLocalized) { |
135 ASSERT_TRUE(RunInstallTest("localized.html", "localized_extension.crx")); | 180 ASSERT_TRUE(RunInstallTest("localized.html", "localized_extension.crx")); |
136 } | 181 } |
137 | 182 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 listener.Wait(); | 216 listener.Wait(); |
172 ASSERT_TRUE(listener.received_success()); | 217 ASSERT_TRUE(listener.received_success()); |
173 ASSERT_EQ("iladmdjkfniedhfhcfoefgojhgaiaccc", listener.id()); | 218 ASSERT_EQ("iladmdjkfniedhfhcfoefgojhgaiaccc", listener.id()); |
174 } | 219 } |
175 | 220 |
176 // Tests using the iconUrl parameter to the install function. | 221 // Tests using the iconUrl parameter to the install function. |
177 IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateApiTest, | 222 IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateApiTest, |
178 IconUrl) { | 223 IconUrl) { |
179 ASSERT_TRUE(RunInstallTest("icon_url.html", "extension.crx")); | 224 ASSERT_TRUE(RunInstallTest("icon_url.html", "extension.crx")); |
180 } | 225 } |
| 226 |
| 227 // Tests using silentlyInstall to install extensions. |
| 228 IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateBundleTest, SilentlyInstall) { |
| 229 WebstorePrivateApi::SetTrustTestIDsForTesting(true); |
| 230 ASSERT_TRUE(RunPageTest(GetTestServerURL("silently_install.html").spec())); |
| 231 } |
OLD | NEW |