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

Side by Side Diff: chrome/browser/ui/zoom/zoom_controller_browsertest.cc

Issue 884063004: Reset manual zoom mode on navigation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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 | « no previous file | components/ui/zoom/zoom_controller.cc » ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/ui/zoom/zoom_controller.h" 5 #include "components/ui/zoom/zoom_controller.h"
6 6
7 #include "base/prefs/pref_service.h" 7 #include "base/prefs/pref_service.h"
8 #include "base/process/kill.h" 8 #include "base/process/kill.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/ui/browser.h" 10 #include "chrome/browser/ui/browser.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 } 57 }
58 58
59 private: 59 private:
60 content::WebContents* web_contents_; 60 content::WebContents* web_contents_;
61 ZoomController::ZoomChangedEventData expected_event_data_; 61 ZoomController::ZoomChangedEventData expected_event_data_;
62 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; 62 scoped_refptr<content::MessageLoopRunner> message_loop_runner_;
63 63
64 DISALLOW_COPY_AND_ASSIGN(ZoomChangedWatcher); 64 DISALLOW_COPY_AND_ASSIGN(ZoomChangedWatcher);
65 }; 65 };
66 66
67 typedef InProcessBrowserTest ZoomControllerBrowserTest; 67 class ZoomControllerBrowserTest : public InProcessBrowserTest {
68 public:
69 ZoomControllerBrowserTest() {}
70 ~ZoomControllerBrowserTest() override {}
71
72 void TestResetOnNavigation(ZoomController::ZoomMode zoom_mode) {
73 DCHECK(zoom_mode == ZoomController::ZOOM_MODE_ISOLATED ||
74 zoom_mode == ZoomController::ZOOM_MODE_MANUAL);
75 content::WebContents* web_contents =
76 browser()->tab_strip_model()->GetActiveWebContents();
77 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete(
78 browser(), GURL("about:blank"), 1);
79 ZoomController* zoom_controller =
80 ZoomController::FromWebContents(web_contents);
81 double zoom_level = zoom_controller->GetDefaultZoomLevel();
82 zoom_controller->SetZoomMode(zoom_mode);
83
84 // When the navigation occurs, the zoom_mode will be reset to
85 // ZOOM_MODE_DEFAULT, and this will be reflected in the event that
86 // is generated.
87 ZoomController::ZoomChangedEventData zoom_change_data(
88 web_contents, zoom_level, zoom_level, ZoomController::ZOOM_MODE_DEFAULT,
89 false);
90 ZoomChangedWatcher zoom_change_watcher(web_contents, zoom_change_data);
91
92 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUISettingsURL));
93 zoom_change_watcher.Wait();
94 }
95 }; // ZoomControllerBrowserTest
68 96
69 #if defined(OS_ANDROID) 97 #if defined(OS_ANDROID)
70 #define MAYBE_CrashedTabsDoNotChangeZoom DISABLED_CrashedTabsDoNotChangeZoom 98 #define MAYBE_CrashedTabsDoNotChangeZoom DISABLED_CrashedTabsDoNotChangeZoom
71 #else 99 #else
72 #define MAYBE_CrashedTabsDoNotChangeZoom CrashedTabsDoNotChangeZoom 100 #define MAYBE_CrashedTabsDoNotChangeZoom CrashedTabsDoNotChangeZoom
73 #endif 101 #endif
74 IN_PROC_BROWSER_TEST_F(ZoomControllerBrowserTest, 102 IN_PROC_BROWSER_TEST_F(ZoomControllerBrowserTest,
75 MAYBE_CrashedTabsDoNotChangeZoom) { 103 MAYBE_CrashedTabsDoNotChangeZoom) {
76 // At the start of the test we are at a tab displaying about:blank. 104 // At the start of the test we are at a tab displaying about:blank.
77 content::WebContents* web_contents = 105 content::WebContents* web_contents =
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 185
158 content::HostZoomMap* host_zoom_map = 186 content::HostZoomMap* host_zoom_map =
159 content::HostZoomMap::GetDefaultForBrowserContext( 187 content::HostZoomMap::GetDefaultForBrowserContext(
160 web_contents->GetBrowserContext()); 188 web_contents->GetBrowserContext());
161 189
162 host_zoom_map->SetZoomLevelForHost("about:blank", new_zoom_level); 190 host_zoom_map->SetZoomLevelForHost("about:blank", new_zoom_level);
163 zoom_change_watcher.Wait(); 191 zoom_change_watcher.Wait();
164 } 192 }
165 193
166 IN_PROC_BROWSER_TEST_F(ZoomControllerBrowserTest, PerTabModeResetSendsEvent) { 194 IN_PROC_BROWSER_TEST_F(ZoomControllerBrowserTest, PerTabModeResetSendsEvent) {
167 content::WebContents* web_contents = 195 TestResetOnNavigation(ZoomController::ZOOM_MODE_ISOLATED);
168 browser()->tab_strip_model()->GetActiveWebContents(); 196 }
169 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete(
170 browser(), GURL("about:blank"), 1);
171 ZoomController* zoom_controller =
172 ZoomController::FromWebContents(web_contents);
173 double zoom_level = zoom_controller->GetDefaultZoomLevel();
174 zoom_controller->SetZoomMode(ZoomController::ZOOM_MODE_ISOLATED);
175 197
176 // When the navigation occurs, the ZOOM_MODE_ISOLATED will be reset to 198 // Regression test: crbug.com/450909.
177 // ZOOM_MODE_DEFAULT, and this will be reflected in the event that 199 IN_PROC_BROWSER_TEST_F(ZoomControllerBrowserTest, NavigationResetsManualMode) {
178 // is generated. 200 TestResetOnNavigation(ZoomController::ZOOM_MODE_MANUAL);
179 ZoomController::ZoomChangedEventData zoom_change_data(
180 web_contents, zoom_level, zoom_level, ZoomController::ZOOM_MODE_DEFAULT,
181 false);
182 ZoomChangedWatcher zoom_change_watcher(web_contents, zoom_change_data);
183
184 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUISettingsURL));
185 zoom_change_watcher.Wait();
186 } 201 }
187 202
188 #if !defined(OS_CHROMEOS) 203 #if !defined(OS_CHROMEOS)
189 // Regression test: crbug.com/438979. 204 // Regression test: crbug.com/438979.
190 IN_PROC_BROWSER_TEST_F(ZoomControllerBrowserTest, 205 IN_PROC_BROWSER_TEST_F(ZoomControllerBrowserTest,
191 SettingsZoomAfterSigninWorks) { 206 SettingsZoomAfterSigninWorks) {
192 GURL signin_url( 207 GURL signin_url(
193 std::string(chrome::kChromeUIChromeSigninURL).append("?source=0")); 208 std::string(chrome::kChromeUIChromeSigninURL).append("?source=0"));
194 // We open the signin page in a new tab so that the ZoomController is 209 // We open the signin page in a new tab so that the ZoomController is
195 // created against the HostZoomMap of the special StoragePartition that 210 // created against the HostZoomMap of the special StoragePartition that
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 web_contents, 262 web_contents,
248 old_zoom_level, 263 old_zoom_level,
249 new_zoom_level, 264 new_zoom_level,
250 ZoomController::ZOOM_MODE_DEFAULT, 265 ZoomController::ZOOM_MODE_DEFAULT,
251 true); // We have a non-empty host, so this will be 'true'. 266 true); // We have a non-empty host, so this will be 'true'.
252 ZoomChangedWatcher zoom_change_watcher(web_contents, zoom_change_data); 267 ZoomChangedWatcher zoom_change_watcher(web_contents, zoom_change_data);
253 zoom_controller->SetZoomLevel(new_zoom_level); 268 zoom_controller->SetZoomLevel(new_zoom_level);
254 zoom_change_watcher.Wait(); 269 zoom_change_watcher.Wait();
255 } 270 }
256 #endif // !defined(OS_CHROMEOS) 271 #endif // !defined(OS_CHROMEOS)
OLDNEW
« no previous file with comments | « no previous file | components/ui/zoom/zoom_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698