Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(245)

Side by Side Diff: chrome/browser/extensions/api/webstore_private/webstore_private_apitest.cc

Issue 16058002: Better workaround for extension browser test problems on win debug bots (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: avoid leaving orphan temp directories Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/file_util.h" 7 #include "base/file_util.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/stringprintf.h" 9 #include "base/stringprintf.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 command_line->AppendSwitchASCII( 99 command_line->AppendSwitchASCII(
100 switches::kAppsGalleryInstallAutoConfirmForTests, "accept"); 100 switches::kAppsGalleryInstallAutoConfirmForTests, "accept");
101 } 101 }
102 102
103 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { 103 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
104 // Start up the test server and get us ready for calling the install 104 // Start up the test server and get us ready for calling the install
105 // API functions. 105 // API functions.
106 host_resolver()->AddRule("www.example.com", "127.0.0.1"); 106 host_resolver()->AddRule("www.example.com", "127.0.0.1");
107 ASSERT_TRUE(test_server()->Start()); 107 ASSERT_TRUE(test_server()->Start());
108 ExtensionInstallUI::DisableFailureUIForTests(); 108 ExtensionInstallUI::DisableFailureUIForTests();
109
110 ASSERT_TRUE(tmp_.CreateUniqueTempDirUnderPath(test_data_dir_));
111 ASSERT_TRUE(file_util::CreateDirectory(tmp_.path()));
112 ASSERT_TRUE(file_util::CopyDirectory(
113 test_data_dir_.AppendASCII("webstore_private"),
114 tmp_.path(),
115 true));
116 } 109 }
117 110
118 protected: 111 protected:
119 // Returns a test server URL, but with host 'www.example.com' so it matches 112 // Returns a test server URL, but with host 'www.example.com' so it matches
120 // the web store app's extent that we set up via command line flags. 113 // the web store app's extent that we set up via command line flags.
121 virtual GURL GetTestServerURL(const std::string& path) { 114 virtual GURL GetTestServerURL(const std::string& path) {
122 std::string basename = tmp_.path().BaseName().MaybeAsASCII();
123 GURL url = test_server()->GetURL( 115 GURL url = test_server()->GetURL(
124 std::string("files/extensions/api_test/") + 116 std::string("files/extensions/api_test/webstore_private/") + path);
125 basename +
126 "/webstore_private/" +
127 path);
128 117
129 // Replace the host with 'www.example.com' so it matches the web store 118 // Replace the host with 'www.example.com' so it matches the web store
130 // app's extent. 119 // app's extent.
131 GURL::Replacements replace_host; 120 GURL::Replacements replace_host;
132 std::string host_str("www.example.com"); 121 std::string host_str("www.example.com");
133 replace_host.SetHostStr(host_str); 122 replace_host.SetHostStr(host_str);
134 123
135 return url.ReplaceComponents(replace_host); 124 return url.ReplaceComponents(replace_host);
136 } 125 }
137 126
138 // Navigates to |page| and runs the Extension API test there. Any downloads 127 // Navigates to |page| and runs the Extension API test there. Any downloads
139 // of extensions will return the contents of |crx_file|. 128 // of extensions will return the contents of |crx_file|.
140 bool RunInstallTest(const std::string& page, const std::string& crx_file) { 129 bool RunInstallTest(const std::string& page, const std::string& crx_file) {
130 #if defined(OS_WIN) && !defined(NDEBUG)
131 // See http://crbug.com/177163 for details.
132 return true;
133 #else
141 GURL crx_url = GetTestServerURL(crx_file); 134 GURL crx_url = GetTestServerURL(crx_file);
142 CommandLine::ForCurrentProcess()->AppendSwitchASCII( 135 CommandLine::ForCurrentProcess()->AppendSwitchASCII(
143 switches::kAppsGalleryUpdateURL, crx_url.spec()); 136 switches::kAppsGalleryUpdateURL, crx_url.spec());
144 137
145 GURL page_url = GetTestServerURL(page); 138 GURL page_url = GetTestServerURL(page);
146 return RunPageTest(page_url.spec()); 139 return RunPageTest(page_url.spec());
140 #endif
147 } 141 }
148 142
149 ExtensionService* service() { 143 ExtensionService* service() {
150 return browser()->profile()->GetExtensionService(); 144 return browser()->profile()->GetExtensionService();
151 } 145 }
152
153 base::ScopedTempDir tmp_;
154 }; 146 };
155 147
156 // Test cases for webstore origin frame blocking. 148 // Test cases for webstore origin frame blocking.
157 // TODO(mkwst): Disabled until new X-Frame-Options behavior rolls into 149 // TODO(mkwst): Disabled until new X-Frame-Options behavior rolls into
158 // Chromium, see crbug.com/226018. 150 // Chromium, see crbug.com/226018.
159 IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateApiTest, 151 IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateApiTest,
160 DISABLED_FrameWebstorePageBlocked) { 152 DISABLED_FrameWebstorePageBlocked) {
161 content::WebContents* contents = 153 content::WebContents* contents =
162 browser()->tab_strip_model()->GetActiveWebContents(); 154 browser()->tab_strip_model()->GetActiveWebContents();
163 string16 expected_title = UTF8ToUTF16("PASS: about:blank"); 155 string16 expected_title = UTF8ToUTF16("PASS: about:blank");
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 } 215 }
224 216
225 IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateApiTest, IncorrectManifest1) { 217 IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateApiTest, IncorrectManifest1) {
226 ASSERT_TRUE(RunInstallTest("incorrect_manifest1.html", "extension.crx")); 218 ASSERT_TRUE(RunInstallTest("incorrect_manifest1.html", "extension.crx"));
227 } 219 }
228 220
229 IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateApiTest, IncorrectManifest2) { 221 IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateApiTest, IncorrectManifest2) {
230 ASSERT_TRUE(RunInstallTest("incorrect_manifest2.html", "extension.crx")); 222 ASSERT_TRUE(RunInstallTest("incorrect_manifest2.html", "extension.crx"));
231 } 223 }
232 224
233 // Disabled: http://crbug.com/174399 225 // Disabled: http://crbug.com/174399 and http://crbug.com/177163
234 #if defined(OS_WIN) && defined(USE_AURA) 226 #if defined(OS_WIN) && (defined(USE_AURA) || !defined(NDEBUG))
235 #define MAYBE_AppInstallBubble DISABLED_AppInstallBubble 227 #define MAYBE_AppInstallBubble DISABLED_AppInstallBubble
236 #else 228 #else
237 #define MAYBE_AppInstallBubble AppInstallBubble 229 #define MAYBE_AppInstallBubble AppInstallBubble
238 #endif 230 #endif
239 231
240 // Tests that we can request an app installed bubble (instead of the default 232 // Tests that we can request an app installed bubble (instead of the default
241 // UI when an app is installed). 233 // UI when an app is installed).
242 IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateApiTest, 234 IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateApiTest,
243 MAYBE_AppInstallBubble) { 235 MAYBE_AppInstallBubble) {
244 WebstoreInstallListener listener; 236 WebstoreInstallListener listener;
245 WebstorePrivateApi::SetWebstoreInstallerDelegateForTesting(&listener); 237 WebstorePrivateApi::SetWebstoreInstallerDelegateForTesting(&listener);
246 ASSERT_TRUE(RunInstallTest("app_install_bubble.html", "app.crx")); 238 ASSERT_TRUE(RunInstallTest("app_install_bubble.html", "app.crx"));
247 listener.Wait(); 239 listener.Wait();
248 ASSERT_TRUE(listener.received_success()); 240 ASSERT_TRUE(listener.received_success());
249 ASSERT_EQ("iladmdjkfniedhfhcfoefgojhgaiaccc", listener.id()); 241 ASSERT_EQ("iladmdjkfniedhfhcfoefgojhgaiaccc", listener.id());
250 } 242 }
251 243
252 // Fails often on Windows dbg bots. http://crbug.com/177163 244 // Fails often on Windows dbg bots. http://crbug.com/177163
253 #if defined(OS_WIN) 245 #if defined(OS_WIN)
254 #define MAYBE_IconUrl DISABLED_IconUrl 246 #define MAYBE_IconUrl DISABLED_IconUrl
255 #else 247 #else
256 #define MAYBE_IconUrl IconUrl 248 #define MAYBE_IconUrl IconUrl
257 #endif // defined(OS_WIN) 249 #endif // defined(OS_WIN)
258 // Tests using the iconUrl parameter to the install function. 250 // Tests using the iconUrl parameter to the install function.
259 IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateApiTest, MAYBE_IconUrl) { 251 IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateApiTest, MAYBE_IconUrl) {
260 ASSERT_TRUE(RunInstallTest("icon_url.html", "extension.crx")); 252 ASSERT_TRUE(RunInstallTest("icon_url.html", "extension.crx"));
261 } 253 }
262 254
255 // http://crbug.com/177163
256 #if defined(OS_WIN) && !defined(NDEBUG)
257 #define MAYBE_BeginInstall DISABLED_BeginInstall
258 #else
259 #define MAYBE_BeginInstall BeginInstall
260 #endif
263 // Tests that the Approvals are properly created in beginInstall. 261 // Tests that the Approvals are properly created in beginInstall.
264 IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateApiTest, BeginInstall) { 262 IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateApiTest, MAYBE_BeginInstall) {
265 std::string appId = "iladmdjkfniedhfhcfoefgojhgaiaccc"; 263 std::string appId = "iladmdjkfniedhfhcfoefgojhgaiaccc";
266 std::string extensionId = "enfkhcelefdadlmkffamgdlgplcionje"; 264 std::string extensionId = "enfkhcelefdadlmkffamgdlgplcionje";
267 ASSERT_TRUE(RunInstallTest("begin_install.html", "extension.crx")); 265 ASSERT_TRUE(RunInstallTest("begin_install.html", "extension.crx"));
268 266
269 scoped_ptr<WebstoreInstaller::Approval> approval = 267 scoped_ptr<WebstoreInstaller::Approval> approval =
270 WebstorePrivateApi::PopApprovalForTesting(browser()->profile(), appId); 268 WebstorePrivateApi::PopApprovalForTesting(browser()->profile(), appId);
271 EXPECT_EQ(appId, approval->extension_id); 269 EXPECT_EQ(appId, approval->extension_id);
272 EXPECT_TRUE(approval->use_app_installed_bubble); 270 EXPECT_TRUE(approval->use_app_installed_bubble);
273 EXPECT_FALSE(approval->skip_post_install_ui); 271 EXPECT_FALSE(approval->skip_post_install_ui);
274 EXPECT_EQ(browser()->profile(), approval->profile); 272 EXPECT_EQ(browser()->profile(), approval->profile);
275 273
276 approval = WebstorePrivateApi::PopApprovalForTesting( 274 approval = WebstorePrivateApi::PopApprovalForTesting(
277 browser()->profile(), extensionId); 275 browser()->profile(), extensionId);
278 EXPECT_EQ(extensionId, approval->extension_id); 276 EXPECT_EQ(extensionId, approval->extension_id);
279 EXPECT_FALSE(approval->use_app_installed_bubble); 277 EXPECT_FALSE(approval->use_app_installed_bubble);
280 EXPECT_FALSE(approval->skip_post_install_ui); 278 EXPECT_FALSE(approval->skip_post_install_ui);
281 EXPECT_EQ(browser()->profile(), approval->profile); 279 EXPECT_EQ(browser()->profile(), approval->profile);
282 } 280 }
283 281
282 // http://crbug.com/177163
283 #if defined(OS_WIN) && !defined(NDEBUG)
284 #define MAYBE_InstallTheme DISABLED_InstallTheme
285 #else
286 #define MAYBE_InstallTheme InstallTheme
287 #endif
284 // Tests that themes are installed without an install prompt. 288 // Tests that themes are installed without an install prompt.
285 IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateApiTest, InstallTheme) { 289 IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateApiTest, MAYBE_InstallTheme) {
286 WebstoreInstallListener listener; 290 WebstoreInstallListener listener;
287 WebstorePrivateApi::SetWebstoreInstallerDelegateForTesting(&listener); 291 WebstorePrivateApi::SetWebstoreInstallerDelegateForTesting(&listener);
288 ASSERT_TRUE(RunInstallTest("theme.html", "../../../theme.crx")); 292 ASSERT_TRUE(RunInstallTest("theme.html", "../../theme.crx"));
289 listener.Wait(); 293 listener.Wait();
290 ASSERT_TRUE(listener.received_success()); 294 ASSERT_TRUE(listener.received_success());
291 ASSERT_EQ("iamefpfkojoapidjnbafmgkgncegbkad", listener.id()); 295 ASSERT_EQ("iamefpfkojoapidjnbafmgkgncegbkad", listener.id());
292 } 296 }
293 297
294 // Tests that an error is properly reported when an empty crx is returned. 298 // Tests that an error is properly reported when an empty crx is returned.
295 IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateApiTest, EmptyCrx) { 299 IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateApiTest, EmptyCrx) {
296 ASSERT_TRUE(RunInstallTest("empty.html", "empty.crx")); 300 ASSERT_TRUE(RunInstallTest("empty.html", "empty.crx"));
297 } 301 }
298 302
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 content::GpuDataManager::GetInstance()->InitializeForTesting( 355 content::GpuDataManager::GetInstance()->InitializeForTesting(
352 json_blacklist, gpu_info); 356 json_blacklist, gpu_info);
353 EXPECT_TRUE(content::GpuDataManager::GetInstance()->IsFeatureBlacklisted( 357 EXPECT_TRUE(content::GpuDataManager::GetInstance()->IsFeatureBlacklisted(
354 gpu::GPU_FEATURE_TYPE_WEBGL)); 358 gpu::GPU_FEATURE_TYPE_WEBGL));
355 359
356 bool webgl_allowed = false; 360 bool webgl_allowed = false;
357 RunTest(webgl_allowed); 361 RunTest(webgl_allowed);
358 } 362 }
359 363
360 } // namespace extensions 364 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698