| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/banners/app_banner_data_fetcher.h" | 5 #include "chrome/browser/banners/app_banner_data_fetcher.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 | 66 |
| 67 void SetUpOnMainThread() override { | 67 void SetUpOnMainThread() override { |
| 68 AppBannerSettingsHelper::SetEngagementWeights(1, 1); | 68 AppBannerSettingsHelper::SetEngagementWeights(1, 1); |
| 69 AppBannerSettingsHelper::SetTotalEngagementToTrigger(2); | 69 AppBannerSettingsHelper::SetTotalEngagementToTrigger(2); |
| 70 ASSERT_TRUE(embedded_test_server()->Start()); | 70 ASSERT_TRUE(embedded_test_server()->Start()); |
| 71 InProcessBrowserTest::SetUpOnMainThread(); | 71 InProcessBrowserTest::SetUpOnMainThread(); |
| 72 } | 72 } |
| 73 | 73 |
| 74 bool HandleNonWebApp(const std::string& platform, | 74 bool HandleNonWebApp(const std::string& platform, |
| 75 const GURL& url, | 75 const GURL& url, |
| 76 const std::string& id) override { | 76 const std::string& id, |
| 77 bool is_debug_mode) override { |
| 77 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, quit_closure_); | 78 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, quit_closure_); |
| 78 non_web_platform_ = platform; | 79 non_web_platform_ = platform; |
| 79 return false; | 80 return false; |
| 80 } | 81 } |
| 81 | 82 |
| 82 void SetUpCommandLine(base::CommandLine* command_line) override { | 83 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 83 command_line->AppendSwitch( | 84 command_line->AppendSwitch( |
| 84 switches::kEnableExperimentalWebPlatformFeatures); | 85 switches::kEnableExperimentalWebPlatformFeatures); |
| 85 // Make sure app banners are disabled in the browser, otherwise they will | 86 // Make sure app banners are disabled in the browser, otherwise they will |
| 86 // interfere with the test. | 87 // interfere with the test. |
| 87 command_line->AppendSwitch(switches::kDisableAddToShelf); | 88 command_line->AppendSwitch(switches::kDisableAddToShelf); |
| 88 } | 89 } |
| 89 | 90 |
| 90 protected: | 91 protected: |
| 91 void RunFetcher(const GURL& url, | 92 void RunFetcher(const GURL& url, |
| 92 const std::string& expected_non_web_platform, | 93 const std::string& expected_non_web_platform, |
| 93 ui::PageTransition transition, | 94 ui::PageTransition transition, |
| 94 bool expected_to_show) { | 95 bool expected_to_show) { |
| 95 content::WebContents* web_contents = | 96 content::WebContents* web_contents = |
| 96 browser()->tab_strip_model()->GetActiveWebContents(); | 97 browser()->tab_strip_model()->GetActiveWebContents(); |
| 97 scoped_refptr<AppBannerDataFetcherDesktop> fetcher( | 98 scoped_refptr<AppBannerDataFetcherDesktop> fetcher( |
| 98 new AppBannerDataFetcherDesktop(web_contents, | 99 new AppBannerDataFetcherDesktop( |
| 99 weak_factory_.GetWeakPtr(), | 100 web_contents, weak_factory_.GetWeakPtr(), 128, 128, false)); |
| 100 128, 128)); | |
| 101 | 101 |
| 102 base::HistogramTester histograms; | 102 base::HistogramTester histograms; |
| 103 base::RunLoop run_loop; | 103 base::RunLoop run_loop; |
| 104 quit_closure_ = run_loop.QuitClosure(); | 104 quit_closure_ = run_loop.QuitClosure(); |
| 105 scoped_ptr<TestObserver> observer(new TestObserver(fetcher.get(), | 105 scoped_ptr<TestObserver> observer(new TestObserver(fetcher.get(), |
| 106 run_loop.QuitClosure())); | 106 run_loop.QuitClosure())); |
| 107 fetcher->Start(url, transition); | 107 fetcher->Start(url, transition); |
| 108 run_loop.Run(); | 108 run_loop.Run(); |
| 109 | 109 |
| 110 EXPECT_EQ(expected_non_web_platform, non_web_platform_); | 110 EXPECT_EQ(expected_non_web_platform, non_web_platform_); |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 RunBannerTest("/banners/prompt_in_handler_test_page.html", | 340 RunBannerTest("/banners/prompt_in_handler_test_page.html", |
| 341 ui::PAGE_TRANSITION_TYPED, 1, true); | 341 ui::PAGE_TRANSITION_TYPED, 1, true); |
| 342 } | 342 } |
| 343 | 343 |
| 344 IN_PROC_BROWSER_TEST_F(AppBannerDataFetcherBrowserTest, WebAppBannerInIFrame) { | 344 IN_PROC_BROWSER_TEST_F(AppBannerDataFetcherBrowserTest, WebAppBannerInIFrame) { |
| 345 RunBannerTest("/banners/iframe_test_page.html", ui::PAGE_TRANSITION_TYPED, 1, | 345 RunBannerTest("/banners/iframe_test_page.html", ui::PAGE_TRANSITION_TYPED, 1, |
| 346 false); | 346 false); |
| 347 } | 347 } |
| 348 | 348 |
| 349 } // namespace banners | 349 } // namespace banners |
| OLD | NEW |