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_dialog.h" |
8 #include "chrome/browser/extensions/extension_install_ui.h" | 8 #include "chrome/browser/extensions/extension_install_ui.h" |
9 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
10 #include "chrome/browser/extensions/extension_webstore_private_api.h" | 10 #include "chrome/browser/extensions/extension_webstore_private_api.h" |
11 #include "chrome/browser/extensions/webstore_installer.h" | 11 #include "chrome/browser/extensions/webstore_installer.h" |
12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/browser/ui/browser.h" | 13 #include "chrome/browser/ui/browser.h" |
14 #include "chrome/common/chrome_notification_types.h" | 14 #include "chrome/common/chrome_notification_types.h" |
15 #include "chrome/common/chrome_switches.h" | 15 #include "chrome/common/chrome_switches.h" |
16 #include "chrome/test/base/ui_test_utils.h" | 16 #include "chrome/test/base/ui_test_utils.h" |
17 #include "content/public/browser/notification_observer.h" | 17 #include "content/public/browser/notification_observer.h" |
18 #include "content/public/browser/notification_registrar.h" | 18 #include "content/public/browser/notification_registrar.h" |
19 #include "net/base/mock_host_resolver.h" | 19 #include "net/base/mock_host_resolver.h" |
20 | 20 |
21 namespace { | 21 namespace { |
22 | 22 |
| 23 const char* kExtensionID = "enfkhcelefdadlmkffamgdlgplcionje"; |
| 24 const char* kAppID = "iladmdjkfniedhfhcfoefgojhgaiaccc"; |
| 25 |
23 class WebstoreInstallListener : public WebstoreInstaller::Delegate { | 26 class WebstoreInstallListener : public WebstoreInstaller::Delegate { |
24 public: | 27 public: |
25 WebstoreInstallListener() | 28 WebstoreInstallListener() |
26 : received_failure_(false), received_success_(false), waiting_(false) {} | 29 : received_failure_(false), received_success_(false), waiting_(false) {} |
27 | 30 |
28 void OnExtensionInstallSuccess(const std::string& id) OVERRIDE; | 31 void OnExtensionInstallSuccess(const std::string& id) OVERRIDE; |
29 void OnExtensionInstallFailure(const std::string& id, | 32 void OnExtensionInstallFailure(const std::string& id, |
30 const std::string& error) OVERRIDE; | 33 const std::string& error) OVERRIDE; |
31 void Wait(); | 34 void Wait(); |
32 | 35 |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 | 166 |
164 // Tests that we can request an app installed bubble (instead of the default | 167 // Tests that we can request an app installed bubble (instead of the default |
165 // UI when an app is installed). | 168 // UI when an app is installed). |
166 IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateApiTest, | 169 IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateApiTest, |
167 AppInstallBubble) { | 170 AppInstallBubble) { |
168 WebstoreInstallListener listener; | 171 WebstoreInstallListener listener; |
169 WebstorePrivateApi::SetWebstoreInstallerDelegateForTesting(&listener); | 172 WebstorePrivateApi::SetWebstoreInstallerDelegateForTesting(&listener); |
170 ASSERT_TRUE(RunInstallTest("app_install_bubble.html", "app.crx")); | 173 ASSERT_TRUE(RunInstallTest("app_install_bubble.html", "app.crx")); |
171 listener.Wait(); | 174 listener.Wait(); |
172 ASSERT_TRUE(listener.received_success()); | 175 ASSERT_TRUE(listener.received_success()); |
173 ASSERT_EQ("iladmdjkfniedhfhcfoefgojhgaiaccc", listener.id()); | 176 ASSERT_EQ(kAppID, listener.id()); |
174 } | 177 } |
175 | 178 |
176 // Tests using the iconUrl parameter to the install function. | 179 // Tests using the iconUrl parameter to the install function. |
177 IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateApiTest, | 180 IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateApiTest, |
178 IconUrl) { | 181 IconUrl) { |
179 ASSERT_TRUE(RunInstallTest("icon_url.html", "extension.crx")); | 182 ASSERT_TRUE(RunInstallTest("icon_url.html", "extension.crx")); |
180 } | 183 } |
| 184 |
| 185 // Tests using silentlyInstall to install extensions. |
| 186 IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateApiTest, SilentlyInstall) { |
| 187 WebstorePrivateApi::SetTrustedIDForTesting(kExtensionID); |
| 188 ASSERT_TRUE(RunInstallTest("silently_install.html", "extension.crx")); |
| 189 } |
OLD | NEW |