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

Side by Side Diff: chrome/browser/installable/installable_manager_browsertest.cc

Issue 2944283002: Replace --add-to-shelf flag with kAppBanners feature. (Closed)
Patch Set: Double Doh! Created 3 years, 6 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "chrome/browser/installable/installable_manager.h" 5 #include "chrome/browser/installable/installable_manager.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/test/scoped_feature_list.h"
10 #include "base/threading/thread_task_runner_handle.h" 11 #include "base/threading/thread_task_runner_handle.h"
11 #include "chrome/browser/ui/browser.h" 12 #include "chrome/browser/ui/browser.h"
12 #include "chrome/browser/ui/tabs/tab_strip_model.h" 13 #include "chrome/browser/ui/tabs/tab_strip_model.h"
13 #include "chrome/common/chrome_switches.h" 14 #include "chrome/common/chrome_features.h"
14 #include "chrome/test/base/in_process_browser_test.h" 15 #include "chrome/test/base/in_process_browser_test.h"
15 #include "chrome/test/base/ui_test_utils.h" 16 #include "chrome/test/base/ui_test_utils.h"
16 #include "content/public/test/browser_test_utils.h" 17 #include "content/public/test/browser_test_utils.h"
17 #include "net/test/embedded_test_server/embedded_test_server.h" 18 #include "net/test/embedded_test_server/embedded_test_server.h"
18 19
19 using IconPurpose = content::Manifest::Icon::IconPurpose; 20 using IconPurpose = content::Manifest::Icon::IconPurpose;
20 21
21 namespace { 22 namespace {
22 23
23 const std::tuple<int, int, IconPurpose> kPrimaryIconParams{144, 144, 24 const std::tuple<int, int, IconPurpose> kPrimaryIconParams{144, 144,
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 GURL primary_icon_url_; 172 GURL primary_icon_url_;
172 std::unique_ptr<SkBitmap> primary_icon_; 173 std::unique_ptr<SkBitmap> primary_icon_;
173 bool is_installable_; 174 bool is_installable_;
174 }; 175 };
175 176
176 class InstallableManagerBrowserTest : public InProcessBrowserTest { 177 class InstallableManagerBrowserTest : public InProcessBrowserTest {
177 public: 178 public:
178 void SetUpOnMainThread() override { 179 void SetUpOnMainThread() override {
179 InProcessBrowserTest::SetUpOnMainThread(); 180 InProcessBrowserTest::SetUpOnMainThread();
180 ASSERT_TRUE(embedded_test_server()->Start()); 181 ASSERT_TRUE(embedded_test_server()->Start());
182
183 // Make sure app banners are disabled in the browser so they do not
184 // interfere with the test.
185 feature_list_.InitAndDisableFeature(features::kAppBanners);
Ilya Sherman 2017/06/22 16:36:22 I'm not 100% sure, but I think this might be runni
benwells 2017/06/23 02:09:26 There is no problem with this, it does affect the
181 } 186 }
182 187
183 // Returns a test server URL to a page controlled by a service worker with 188 // Returns a test server URL to a page controlled by a service worker with
184 // |manifest_url| injected as the manifest tag. 189 // |manifest_url| injected as the manifest tag.
185 std::string GetURLOfPageWithServiceWorkerAndManifest( 190 std::string GetURLOfPageWithServiceWorkerAndManifest(
186 const std::string& manifest_url) { 191 const std::string& manifest_url) {
187 return "/banners/manifest_test_page.html?manifest=" + 192 return "/banners/manifest_test_page.html?manifest=" +
188 embedded_test_server()->GetURL(manifest_url).spec(); 193 embedded_test_server()->GetURL(manifest_url).spec();
189 } 194 }
190 195
191 void NavigateAndRunInstallableManager(CallbackTester* tester, 196 void NavigateAndRunInstallableManager(CallbackTester* tester,
192 const InstallableParams& params, 197 const InstallableParams& params,
193 const std::string& url) { 198 const std::string& url) {
194 GURL test_url = embedded_test_server()->GetURL(url); 199 GURL test_url = embedded_test_server()->GetURL(url);
195 ui_test_utils::NavigateToURL(browser(), test_url); 200 ui_test_utils::NavigateToURL(browser(), test_url);
196 RunInstallableManager(tester, params); 201 RunInstallableManager(tester, params);
197 } 202 }
198 203
199 void RunInstallableManager(CallbackTester* tester, 204 void RunInstallableManager(CallbackTester* tester,
200 const InstallableParams& params) { 205 const InstallableParams& params) {
201 InstallableManager* manager = GetManager(); 206 InstallableManager* manager = GetManager();
202 manager->GetData(params, 207 manager->GetData(params,
203 base::Bind(&CallbackTester::OnDidFinishInstallableCheck, 208 base::Bind(&CallbackTester::OnDidFinishInstallableCheck,
204 base::Unretained(tester))); 209 base::Unretained(tester)));
205 } 210 }
206 211
207 void SetUpCommandLine(base::CommandLine* command_line) override {
208 // Make sure app banners are disabled in the browser so they do not
209 // interfere with the test.
210 command_line->AppendSwitch(switches::kDisableAddToShelf);
211 }
212
213 InstallableManager* GetManager() { 212 InstallableManager* GetManager() {
214 content::WebContents* web_contents = 213 content::WebContents* web_contents =
215 browser()->tab_strip_model()->GetActiveWebContents(); 214 browser()->tab_strip_model()->GetActiveWebContents();
216 InstallableManager::CreateForWebContents(web_contents); 215 InstallableManager::CreateForWebContents(web_contents);
217 InstallableManager* manager = 216 InstallableManager* manager =
218 InstallableManager::FromWebContents(web_contents); 217 InstallableManager::FromWebContents(web_contents);
219 CHECK(manager); 218 CHECK(manager);
220 219
221 return manager; 220 return manager;
222 } 221 }
223 222
224 InstallabilityCheckStatus GetStatus() { return GetManager()->page_status_; } 223 InstallabilityCheckStatus GetStatus() { return GetManager()->page_status_; }
224
225 private:
226 base::test::ScopedFeatureList feature_list_;
225 }; 227 };
226 228
227 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest, 229 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest,
228 ManagerBeginsInEmptyState) { 230 ManagerBeginsInEmptyState) {
229 // Ensure that the InstallableManager starts off with everything null. 231 // Ensure that the InstallableManager starts off with everything null.
230 InstallableManager* manager = GetManager(); 232 InstallableManager* manager = GetManager();
231 233
232 EXPECT_TRUE(manager->manifest().IsEmpty()); 234 EXPECT_TRUE(manager->manifest().IsEmpty());
233 EXPECT_TRUE(manager->manifest_url().is_empty()); 235 EXPECT_TRUE(manager->manifest_url().is_empty());
234 EXPECT_TRUE(manager->icons_.empty()); 236 EXPECT_TRUE(manager->icons_.empty());
(...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after
1037 CheckNestedCallsToGetData) { 1039 CheckNestedCallsToGetData) {
1038 // Verify that we can call GetData while in a callback from GetData. 1040 // Verify that we can call GetData while in a callback from GetData.
1039 base::RunLoop run_loop; 1041 base::RunLoop run_loop;
1040 InstallableParams params = GetWebAppParams(); 1042 InstallableParams params = GetWebAppParams();
1041 std::unique_ptr<NestedCallbackTester> tester( 1043 std::unique_ptr<NestedCallbackTester> tester(
1042 new NestedCallbackTester(GetManager(), params, run_loop.QuitClosure())); 1044 new NestedCallbackTester(GetManager(), params, run_loop.QuitClosure()));
1043 1045
1044 tester->Run(); 1046 tester->Run();
1045 run_loop.Run(); 1047 run_loop.Run();
1046 } 1048 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698