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

Side by Side Diff: chrome/browser/prerender/prerender_browsertest.cc

Issue 1059743003: Remove NOTIFICATION_FAVICON_UPDATED (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@get-active-title
Patch Set: Add DISALLOW_COPY_AND_ASSIGN(FaviconUpdateWatcher) Created 5 years, 8 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 (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 <deque> 5 #include <deque>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
11 #include "base/macros.h"
11 #include "base/memory/ref_counted_memory.h" 12 #include "base/memory/ref_counted_memory.h"
12 #include "base/memory/scoped_vector.h" 13 #include "base/memory/scoped_vector.h"
13 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
14 #include "base/path_service.h" 15 #include "base/path_service.h"
15 #include "base/prefs/pref_service.h" 16 #include "base/prefs/pref_service.h"
16 #include "base/run_loop.h" 17 #include "base/run_loop.h"
18 #include "base/scoped_observer.h"
17 #include "base/strings/string_util.h" 19 #include "base/strings/string_util.h"
18 #include "base/strings/stringprintf.h" 20 #include "base/strings/stringprintf.h"
19 #include "base/strings/utf_string_conversions.h" 21 #include "base/strings/utf_string_conversions.h"
20 #include "base/test/histogram_tester.h" 22 #include "base/test/histogram_tester.h"
21 #include "base/test/test_timeouts.h" 23 #include "base/test/test_timeouts.h"
22 #include "base/values.h" 24 #include "base/values.h"
23 #include "chrome/browser/browsing_data/browsing_data_helper.h" 25 #include "chrome/browser/browsing_data/browsing_data_helper.h"
24 #include "chrome/browser/browsing_data/browsing_data_remover.h" 26 #include "chrome/browser/browsing_data/browsing_data_remover.h"
25 #include "chrome/browser/browsing_data/browsing_data_remover_test_util.h" 27 #include "chrome/browser/browsing_data/browsing_data_remover_test_util.h"
26 #include "chrome/browser/chrome_content_browser_client.h" 28 #include "chrome/browser/chrome_content_browser_client.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 #include "chrome/browser/ui/tabs/tab_strip_model.h" 61 #include "chrome/browser/ui/tabs/tab_strip_model.h"
60 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" 62 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h"
61 #include "chrome/common/chrome_paths.h" 63 #include "chrome/common/chrome_paths.h"
62 #include "chrome/common/chrome_switches.h" 64 #include "chrome/common/chrome_switches.h"
63 #include "chrome/common/pref_names.h" 65 #include "chrome/common/pref_names.h"
64 #include "chrome/grit/generated_resources.h" 66 #include "chrome/grit/generated_resources.h"
65 #include "chrome/test/base/in_process_browser_test.h" 67 #include "chrome/test/base/in_process_browser_test.h"
66 #include "chrome/test/base/test_switches.h" 68 #include "chrome/test/base/test_switches.h"
67 #include "chrome/test/base/ui_test_utils.h" 69 #include "chrome/test/base/ui_test_utils.h"
68 #include "components/content_settings/core/browser/host_content_settings_map.h" 70 #include "components/content_settings/core/browser/host_content_settings_map.h"
71 #include "components/favicon/core/favicon_driver_observer.h"
69 #include "components/variations/entropy_provider.h" 72 #include "components/variations/entropy_provider.h"
70 #include "components/variations/variations_associated_data.h" 73 #include "components/variations/variations_associated_data.h"
71 #include "content/public/browser/browser_message_filter.h" 74 #include "content/public/browser/browser_message_filter.h"
72 #include "content/public/browser/devtools_agent_host.h" 75 #include "content/public/browser/devtools_agent_host.h"
73 #include "content/public/browser/navigation_controller.h" 76 #include "content/public/browser/navigation_controller.h"
74 #include "content/public/browser/navigation_entry.h" 77 #include "content/public/browser/navigation_entry.h"
75 #include "content/public/browser/notification_service.h" 78 #include "content/public/browser/notification_service.h"
76 #include "content/public/browser/render_frame_host.h" 79 #include "content/public/browser/render_frame_host.h"
77 #include "content/public/browser/render_process_host.h" 80 #include "content/public/browser/render_process_host.h"
78 #include "content/public/browser/render_view_host.h" 81 #include "content/public/browser/render_view_host.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 // the page behaves as expected when prerendered. 127 // the page behaves as expected when prerendered.
125 // 128 //
126 // The prerendered page is then displayed on a tab. The Javascript function 129 // The prerendered page is then displayed on a tab. The Javascript function
127 // DidDisplayPass() is called, and returns true if the page behaved as it 130 // DidDisplayPass() is called, and returns true if the page behaved as it
128 // should while being displayed. 131 // should while being displayed.
129 132
130 namespace prerender { 133 namespace prerender {
131 134
132 namespace { 135 namespace {
133 136
137 class FaviconUpdateWatcher : public favicon::FaviconDriverObserver {
138 public:
139 explicit FaviconUpdateWatcher(content::WebContents* web_contents)
140 : seen_(false), running_(false), scoped_observer_(this) {
141 scoped_observer_.Add(FaviconTabHelper::FromWebContents(web_contents));
142 }
143
144 void Wait() {
145 if (seen_)
146 return;
147
148 running_ = true;
149 message_loop_runner_ = new content::MessageLoopRunner;
150 message_loop_runner_->Run();
151 }
152
153 private:
154 void OnFaviconAvailable(const gfx::Image& image) override {}
155 void OnFaviconUpdated(favicon::FaviconDriver* favicon_driver,
156 bool icon_url_changed) override {
157 seen_ = true;
158 if (!running_)
159 return;
160
161 message_loop_runner_->Quit();
162 running_ = false;
163 }
164
165 bool seen_;
166 bool running_;
167 ScopedObserver<FaviconTabHelper, FaviconUpdateWatcher> scoped_observer_;
168 scoped_refptr<content::MessageLoopRunner> message_loop_runner_;
169
170 DISALLOW_COPY_AND_ASSIGN(FaviconUpdateWatcher);
171 };
172
134 class MockNetworkChangeNotifierWIFI : public NetworkChangeNotifier { 173 class MockNetworkChangeNotifierWIFI : public NetworkChangeNotifier {
135 public: 174 public:
136 ConnectionType GetCurrentConnectionType() const override { 175 ConnectionType GetCurrentConnectionType() const override {
137 return NetworkChangeNotifier::CONNECTION_WIFI; 176 return NetworkChangeNotifier::CONNECTION_WIFI;
138 } 177 }
139 }; 178 };
140 179
141 class MockNetworkChangeNotifier4G : public NetworkChangeNotifier { 180 class MockNetworkChangeNotifier4G : public NetworkChangeNotifier {
142 public: 181 public:
143 ConnectionType GetCurrentConnectionType() const override { 182 ConnectionType GetCurrentConnectionType() const override {
(...skipping 2995 matching lines...) Expand 10 before | Expand all | Expand 10 after
3139 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderFavicon) { 3178 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderFavicon) {
3140 scoped_ptr<TestPrerender> prerender = 3179 scoped_ptr<TestPrerender> prerender =
3141 PrerenderTestURL("files/prerender/prerender_favicon.html", 3180 PrerenderTestURL("files/prerender/prerender_favicon.html",
3142 FINAL_STATUS_USED, 3181 FINAL_STATUS_USED,
3143 1); 3182 1);
3144 NavigateToDestURL(); 3183 NavigateToDestURL();
3145 3184
3146 if (!FaviconTabHelper::FromWebContents( 3185 if (!FaviconTabHelper::FromWebContents(
3147 GetActiveWebContents())->FaviconIsValid()) { 3186 GetActiveWebContents())->FaviconIsValid()) {
3148 // If the favicon has not been set yet, wait for it to be. 3187 // If the favicon has not been set yet, wait for it to be.
3149 content::WindowedNotificationObserver favicon_update_watcher( 3188 FaviconUpdateWatcher favicon_update_watcher(GetActiveWebContents());
3150 chrome::NOTIFICATION_FAVICON_UPDATED,
3151 content::Source<WebContents>(GetActiveWebContents()));
3152 favicon_update_watcher.Wait(); 3189 favicon_update_watcher.Wait();
3153 } 3190 }
3154 EXPECT_TRUE(FaviconTabHelper::FromWebContents( 3191 EXPECT_TRUE(FaviconTabHelper::FromWebContents(
3155 GetActiveWebContents())->FaviconIsValid()); 3192 GetActiveWebContents())->FaviconIsValid());
3156 } 3193 }
3157 3194
3158 // Checks that when a prerendered page is swapped in to a referring page, the 3195 // Checks that when a prerendered page is swapped in to a referring page, the
3159 // unload handlers on the referring page are executed. 3196 // unload handlers on the referring page are executed.
3160 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderUnload) { 3197 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderUnload) {
3161 // Matches URL in prerender_loader_with_unload.html. 3198 // Matches URL in prerender_loader_with_unload.html.
(...skipping 952 matching lines...) Expand 10 before | Expand all | Expand 10 after
4114 TestShouldDisableLocalPredictorPreferenceNetworkMatrix( 4151 TestShouldDisableLocalPredictorPreferenceNetworkMatrix(
4115 false /*preference_wifi_network_wifi*/, 4152 false /*preference_wifi_network_wifi*/,
4116 false /*preference_wifi_network_4g*/, 4153 false /*preference_wifi_network_4g*/,
4117 false /*preference_always_network_wifi*/, 4154 false /*preference_always_network_wifi*/,
4118 false /*preference_always_network_4g*/, 4155 false /*preference_always_network_4g*/,
4119 false /*preference_never_network_wifi*/, 4156 false /*preference_never_network_wifi*/,
4120 false /*preference_never_network_4g*/); 4157 false /*preference_never_network_4g*/);
4121 } 4158 }
4122 4159
4123 } // namespace prerender 4160 } // namespace prerender
OLDNEW
« no previous file with comments | « chrome/browser/favicon/favicon_tab_helper_browsertest.cc ('k') | components/favicon/core/favicon_driver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698