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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/stringprintf.h" | 6 #include "base/stringprintf.h" |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "chrome/browser/extensions/extension_host.h" | 8 #include "chrome/browser/extensions/extension_host.h" |
9 #include "chrome/browser/extensions/extension_install_dialog.h" | 9 #include "chrome/browser/extensions/extension_install_dialog.h" |
10 #include "chrome/browser/extensions/extension_install_ui.h" | 10 #include "chrome/browser/extensions/extension_install_ui.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "googleurl/src/gurl.h" | 21 #include "googleurl/src/gurl.h" |
22 #include "net/base/host_port_pair.h" | 22 #include "net/base/host_port_pair.h" |
23 #include "net/base/mock_host_resolver.h" | 23 #include "net/base/mock_host_resolver.h" |
24 | 24 |
25 using content::WebContents; | 25 using content::WebContents; |
26 | 26 |
27 const char kWebstoreDomain[] = "cws.com"; | 27 const char kWebstoreDomain[] = "cws.com"; |
28 const char kAppDomain[] = "app.com"; | 28 const char kAppDomain[] = "app.com"; |
29 const char kNonAppDomain[] = "nonapp.com"; | 29 const char kNonAppDomain[] = "nonapp.com"; |
30 | 30 |
| 31 // http://crbug.com/113024 |
| 32 #if !defined(NDEBUG) && (defined(OS_WIN) || defined(OS_MACOSX)) |
| 33 #define MAYBE(TestName) DISABLED_ ## TestName |
| 34 #else |
| 35 #define MAYBE(TestName) TestName |
| 36 #endif |
| 37 |
31 class WebstoreInlineInstallTest : public InProcessBrowserTest { | 38 class WebstoreInlineInstallTest : public InProcessBrowserTest { |
32 public: | 39 public: |
33 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 40 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
34 EnableDOMAutomation(); | 41 EnableDOMAutomation(); |
35 | 42 |
36 // We start the test server now instead of in | 43 // We start the test server now instead of in |
37 // SetUpInProcessBrowserTestFixture so that we can get its port number. | 44 // SetUpInProcessBrowserTestFixture so that we can get its port number. |
38 ASSERT_TRUE(test_server()->Start()); | 45 ASSERT_TRUE(test_server()->Start()); |
39 | 46 |
40 InProcessBrowserTest::SetUpCommandLine(command_line); | 47 InProcessBrowserTest::SetUpCommandLine(command_line); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 test_gallery_url_.c_str()); | 81 test_gallery_url_.c_str()); |
75 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 82 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
76 browser()->GetSelectedWebContents()->GetRenderViewHost(), L"", | 83 browser()->GetSelectedWebContents()->GetRenderViewHost(), L"", |
77 UTF8ToWide(script), &result)); | 84 UTF8ToWide(script), &result)); |
78 EXPECT_TRUE(result); | 85 EXPECT_TRUE(result); |
79 } | 86 } |
80 | 87 |
81 std::string test_gallery_url_; | 88 std::string test_gallery_url_; |
82 }; | 89 }; |
83 | 90 |
84 IN_PROC_BROWSER_TEST_F(WebstoreInlineInstallTest, Install) { | 91 IN_PROC_BROWSER_TEST_F(WebstoreInlineInstallTest, MAYBE(Install)) { |
85 CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 92 CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
86 switches::kAppsGalleryInstallAutoConfirmForTests, "accept"); | 93 switches::kAppsGalleryInstallAutoConfirmForTests, "accept"); |
87 | 94 |
88 ui_test_utils::NavigateToURL( | 95 ui_test_utils::NavigateToURL( |
89 browser(), GenerateTestServerUrl(kAppDomain, "install.html")); | 96 browser(), GenerateTestServerUrl(kAppDomain, "install.html")); |
90 | 97 |
91 RunInlineInstallTest("runTest"); | 98 RunInlineInstallTest("runTest"); |
92 | 99 |
93 const Extension* extension = browser()->profile()->GetExtensionService()-> | 100 const Extension* extension = browser()->profile()->GetExtensionService()-> |
94 GetExtensionById("ecglahbcnmdpdciemllbhojghbkagdje", false); | 101 GetExtensionById("ecglahbcnmdpdciemllbhojghbkagdje", false); |
95 EXPECT_TRUE(extension); | 102 EXPECT_TRUE(extension); |
96 } | 103 } |
97 | 104 |
98 IN_PROC_BROWSER_TEST_F( | 105 IN_PROC_BROWSER_TEST_F(WebstoreInlineInstallTest, |
99 WebstoreInlineInstallTest, InstallNotAllowedFromNonVerifiedDomains) { | 106 MAYBE(InstallNotAllowedFromNonVerifiedDomains)) { |
100 CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 107 CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
101 switches::kAppsGalleryInstallAutoConfirmForTests, "cancel"); | 108 switches::kAppsGalleryInstallAutoConfirmForTests, "cancel"); |
102 ui_test_utils::NavigateToURL( | 109 ui_test_utils::NavigateToURL( |
103 browser(), | 110 browser(), |
104 GenerateTestServerUrl(kNonAppDomain, "install_non_verified_domain.html")); | 111 GenerateTestServerUrl(kNonAppDomain, "install_non_verified_domain.html")); |
105 | 112 |
106 RunInlineInstallTest("runTest1"); | 113 RunInlineInstallTest("runTest1"); |
107 RunInlineInstallTest("runTest2"); | 114 RunInlineInstallTest("runTest2"); |
108 } | 115 } |
109 | 116 |
110 IN_PROC_BROWSER_TEST_F(WebstoreInlineInstallTest, FindLink) { | 117 IN_PROC_BROWSER_TEST_F(WebstoreInlineInstallTest, FindLink) { |
111 ui_test_utils::NavigateToURL( | 118 ui_test_utils::NavigateToURL( |
112 browser(), GenerateTestServerUrl(kAppDomain, "find_link.html")); | 119 browser(), GenerateTestServerUrl(kAppDomain, "find_link.html")); |
113 | 120 |
114 RunInlineInstallTest("runTest"); | 121 RunInlineInstallTest("runTest"); |
115 } | 122 } |
116 | 123 |
117 IN_PROC_BROWSER_TEST_F(WebstoreInlineInstallTest, ArgumentValidation) { | 124 IN_PROC_BROWSER_TEST_F(WebstoreInlineInstallTest, ArgumentValidation) { |
118 CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 125 CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
119 switches::kAppsGalleryInstallAutoConfirmForTests, "cancel"); | 126 switches::kAppsGalleryInstallAutoConfirmForTests, "cancel"); |
120 ui_test_utils::NavigateToURL( | 127 ui_test_utils::NavigateToURL( |
121 browser(), GenerateTestServerUrl(kAppDomain, "argument_validation.html")); | 128 browser(), GenerateTestServerUrl(kAppDomain, "argument_validation.html")); |
122 | 129 |
123 RunInlineInstallTest("runTest"); | 130 RunInlineInstallTest("runTest"); |
124 } | 131 } |
125 | 132 |
126 IN_PROC_BROWSER_TEST_F(WebstoreInlineInstallTest, InstallNotSupported) { | 133 IN_PROC_BROWSER_TEST_F(WebstoreInlineInstallTest, |
| 134 MAYBE(InstallNotSupported)) { |
127 CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 135 CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
128 switches::kAppsGalleryInstallAutoConfirmForTests, "cancel"); | 136 switches::kAppsGalleryInstallAutoConfirmForTests, "cancel"); |
129 ui_test_utils::NavigateToURL( | 137 ui_test_utils::NavigateToURL( |
130 browser(), | 138 browser(), |
131 GenerateTestServerUrl(kAppDomain, "install_not_supported.html")); | 139 GenerateTestServerUrl(kAppDomain, "install_not_supported.html")); |
132 | 140 |
133 RunInlineInstallTest("runTest"); | 141 RunInlineInstallTest("runTest"); |
134 | 142 |
135 // The inline install should fail, and a store-provided URL should be opened | 143 // The inline install should fail, and a store-provided URL should be opened |
136 // in a new tab. | 144 // in a new tab. |
(...skipping 17 matching lines...) Expand all Loading... |
154 CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 162 CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
155 switches::kAppsGalleryUpdateURL, crx_url.spec()); | 163 switches::kAppsGalleryUpdateURL, crx_url.spec()); |
156 } | 164 } |
157 | 165 |
158 void SetUpInProcessBrowserTestFixture() OVERRIDE { | 166 void SetUpInProcessBrowserTestFixture() OVERRIDE { |
159 WebstoreInlineInstallTest::SetUpInProcessBrowserTestFixture(); | 167 WebstoreInlineInstallTest::SetUpInProcessBrowserTestFixture(); |
160 ExtensionInstallUI::DisableFailureUIForTests(); | 168 ExtensionInstallUI::DisableFailureUIForTests(); |
161 } | 169 } |
162 }; | 170 }; |
163 | 171 |
164 IN_PROC_BROWSER_TEST_F(WebstoreInlineInstallUnpackFailureTest, Test) { | 172 IN_PROC_BROWSER_TEST_F(WebstoreInlineInstallUnpackFailureTest, |
| 173 MAYBE(WebstoreInlineInstallUnpackFailureTest)) { |
165 CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 174 CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
166 switches::kAppsGalleryInstallAutoConfirmForTests, "accept"); | 175 switches::kAppsGalleryInstallAutoConfirmForTests, "accept"); |
167 | 176 |
168 ui_test_utils::NavigateToURL(browser(), | 177 ui_test_utils::NavigateToURL(browser(), |
169 GenerateTestServerUrl(kAppDomain, "install_unpack_failure.html")); | 178 GenerateTestServerUrl(kAppDomain, "install_unpack_failure.html")); |
170 | 179 |
171 RunInlineInstallTest("runTest"); | 180 RunInlineInstallTest("runTest"); |
172 } | 181 } |
OLD | NEW |