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/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "base/task_runner.h" | 10 #include "base/task_runner.h" |
| 11 #include "chrome/browser/banners/app_banner_data_fetcher_desktop.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/test/base/in_process_browser_test.h" | 14 #include "chrome/test/base/in_process_browser_test.h" |
14 #include "chrome/test/base/ui_test_utils.h" | 15 #include "chrome/test/base/ui_test_utils.h" |
15 #include "content/public/common/content_switches.h" | 16 #include "content/public/common/content_switches.h" |
16 #include "content/public/test/test_navigation_observer.h" | 17 #include "content/public/test/test_navigation_observer.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 namespace banners { | 20 namespace banners { |
20 | 21 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 command_line->AppendSwitch( | 75 command_line->AppendSwitch( |
75 switches::kEnableExperimentalWebPlatformFeatures); | 76 switches::kEnableExperimentalWebPlatformFeatures); |
76 } | 77 } |
77 | 78 |
78 protected: | 79 protected: |
79 void RunFetcher(const GURL& url, | 80 void RunFetcher(const GURL& url, |
80 const std::string& expected_non_web_platform, | 81 const std::string& expected_non_web_platform, |
81 bool expected_to_show) { | 82 bool expected_to_show) { |
82 content::WebContents* web_contents = | 83 content::WebContents* web_contents = |
83 browser()->tab_strip_model()->GetActiveWebContents(); | 84 browser()->tab_strip_model()->GetActiveWebContents(); |
84 scoped_refptr<AppBannerDataFetcher> fetcher( | 85 scoped_refptr<AppBannerDataFetcherDesktop> fetcher( |
85 new AppBannerDataFetcher(web_contents, weak_factory_.GetWeakPtr(), | 86 new AppBannerDataFetcherDesktop(web_contents, |
86 128)); | 87 weak_factory_.GetWeakPtr(), 128)); |
87 | 88 |
88 base::RunLoop run_loop; | 89 base::RunLoop run_loop; |
89 quit_closure_ = run_loop.QuitClosure(); | 90 quit_closure_ = run_loop.QuitClosure(); |
90 scoped_ptr<TestObserver> observer(new TestObserver(fetcher.get(), | 91 scoped_ptr<TestObserver> observer(new TestObserver(fetcher.get(), |
91 run_loop.QuitClosure())); | 92 run_loop.QuitClosure())); |
92 fetcher->Start(url); | 93 fetcher->Start(url); |
93 run_loop.Run(); | 94 run_loop.Run(); |
94 | 95 |
95 EXPECT_EQ(expected_non_web_platform, non_web_platform_); | 96 EXPECT_EQ(expected_non_web_platform, non_web_platform_); |
96 EXPECT_EQ(expected_to_show, observer->will_show()); | 97 EXPECT_EQ(expected_to_show, observer->will_show()); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 LoadURLAndWaitForServiceWorker(test_url); | 182 LoadURLAndWaitForServiceWorker(test_url); |
182 RunFetcher(web_contents->GetURL(), std::string(), false); | 183 RunFetcher(web_contents->GetURL(), std::string(), false); |
183 | 184 |
184 // Advance by a day, then visit the page again to trigger the banner. | 185 // Advance by a day, then visit the page again to trigger the banner. |
185 AppBannerDataFetcher::SetTimeDeltaForTesting(1); | 186 AppBannerDataFetcher::SetTimeDeltaForTesting(1); |
186 LoadURLAndWaitForServiceWorker(test_url); | 187 LoadURLAndWaitForServiceWorker(test_url); |
187 RunFetcher(web_contents->GetURL(), std::string(), false); | 188 RunFetcher(web_contents->GetURL(), std::string(), false); |
188 } | 189 } |
189 | 190 |
190 } // namespace banners | 191 } // namespace banners |
OLD | NEW |