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

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

Issue 2944283002: Replace --add-to-shelf flag with kAppBanners feature. (Closed)
Patch Set: Rebase Created 3 years, 5 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
« no previous file with comments | « chrome/browser/flag_descriptions.cc ('k') | chrome/common/chrome_features.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 content::Manifest manifest_; 171 content::Manifest manifest_;
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 ASSERT_TRUE(embedded_test_server()->Start()); 180 ASSERT_TRUE(embedded_test_server()->Start());
181
182 // Make sure app banners are disabled in the browser so they do not
183 // interfere with the test.
184 feature_list_.InitAndDisableFeature(features::kAppBanners);
180 } 185 }
181 186
182 // Returns a test server URL to a page controlled by a service worker with 187 // Returns a test server URL to a page controlled by a service worker with
183 // |manifest_url| injected as the manifest tag. 188 // |manifest_url| injected as the manifest tag.
184 std::string GetURLOfPageWithServiceWorkerAndManifest( 189 std::string GetURLOfPageWithServiceWorkerAndManifest(
185 const std::string& manifest_url) { 190 const std::string& manifest_url) {
186 return "/banners/manifest_test_page.html?manifest=" + 191 return "/banners/manifest_test_page.html?manifest=" +
187 embedded_test_server()->GetURL(manifest_url).spec(); 192 embedded_test_server()->GetURL(manifest_url).spec();
188 } 193 }
189 194
190 void NavigateAndRunInstallableManager(CallbackTester* tester, 195 void NavigateAndRunInstallableManager(CallbackTester* tester,
191 const InstallableParams& params, 196 const InstallableParams& params,
192 const std::string& url) { 197 const std::string& url) {
193 GURL test_url = embedded_test_server()->GetURL(url); 198 GURL test_url = embedded_test_server()->GetURL(url);
194 ui_test_utils::NavigateToURL(browser(), test_url); 199 ui_test_utils::NavigateToURL(browser(), test_url);
195 RunInstallableManager(tester, params); 200 RunInstallableManager(tester, params);
196 } 201 }
197 202
198 void RunInstallableManager(CallbackTester* tester, 203 void RunInstallableManager(CallbackTester* tester,
199 const InstallableParams& params) { 204 const InstallableParams& params) {
200 InstallableManager* manager = GetManager(); 205 InstallableManager* manager = GetManager();
201 manager->GetData(params, 206 manager->GetData(params,
202 base::Bind(&CallbackTester::OnDidFinishInstallableCheck, 207 base::Bind(&CallbackTester::OnDidFinishInstallableCheck,
203 base::Unretained(tester))); 208 base::Unretained(tester)));
204 } 209 }
205 210
206 void SetUpCommandLine(base::CommandLine* command_line) override {
207 // Make sure app banners are disabled in the browser so they do not
208 // interfere with the test.
209 command_line->AppendSwitch(switches::kDisableAddToShelf);
210 }
211
212 InstallableManager* GetManager() { 211 InstallableManager* GetManager() {
213 content::WebContents* web_contents = 212 content::WebContents* web_contents =
214 browser()->tab_strip_model()->GetActiveWebContents(); 213 browser()->tab_strip_model()->GetActiveWebContents();
215 InstallableManager::CreateForWebContents(web_contents); 214 InstallableManager::CreateForWebContents(web_contents);
216 InstallableManager* manager = 215 InstallableManager* manager =
217 InstallableManager::FromWebContents(web_contents); 216 InstallableManager::FromWebContents(web_contents);
218 CHECK(manager); 217 CHECK(manager);
219 218
220 return manager; 219 return manager;
221 } 220 }
222 221
223 InstallabilityCheckStatus GetStatus() { return GetManager()->page_status_; } 222 InstallabilityCheckStatus GetStatus() { return GetManager()->page_status_; }
223
224 private:
225 base::test::ScopedFeatureList feature_list_;
224 }; 226 };
225 227
226 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest, 228 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest,
227 ManagerBeginsInEmptyState) { 229 ManagerBeginsInEmptyState) {
228 // Ensure that the InstallableManager starts off with everything null. 230 // Ensure that the InstallableManager starts off with everything null.
229 InstallableManager* manager = GetManager(); 231 InstallableManager* manager = GetManager();
230 232
231 EXPECT_TRUE(manager->manifest().IsEmpty()); 233 EXPECT_TRUE(manager->manifest().IsEmpty());
232 EXPECT_TRUE(manager->manifest_url().is_empty()); 234 EXPECT_TRUE(manager->manifest_url().is_empty());
233 EXPECT_TRUE(manager->icons_.empty()); 235 EXPECT_TRUE(manager->icons_.empty());
(...skipping 825 matching lines...) Expand 10 before | Expand all | Expand 10 after
1059 CheckNestedCallsToGetData) { 1061 CheckNestedCallsToGetData) {
1060 // Verify that we can call GetData while in a callback from GetData. 1062 // Verify that we can call GetData while in a callback from GetData.
1061 base::RunLoop run_loop; 1063 base::RunLoop run_loop;
1062 InstallableParams params = GetWebAppParams(); 1064 InstallableParams params = GetWebAppParams();
1063 std::unique_ptr<NestedCallbackTester> tester( 1065 std::unique_ptr<NestedCallbackTester> tester(
1064 new NestedCallbackTester(GetManager(), params, run_loop.QuitClosure())); 1066 new NestedCallbackTester(GetManager(), params, run_loop.QuitClosure()));
1065 1067
1066 tester->Run(); 1068 tester->Run();
1067 run_loop.Run(); 1069 run_loop.Run();
1068 } 1070 }
OLDNEW
« no previous file with comments | « chrome/browser/flag_descriptions.cc ('k') | chrome/common/chrome_features.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698