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

Side by Side Diff: chrome/browser/profiles/host_zoom_map_browsertest.cc

Issue 2019423005: Move //components/ui/zoom to top-level under //components (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 6 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 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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 16 matching lines...) Expand all
27 #include "chrome/common/chrome_constants.h" 27 #include "chrome/common/chrome_constants.h"
28 #include "chrome/common/chrome_paths.h" 28 #include "chrome/common/chrome_paths.h"
29 #include "chrome/common/pref_names.h" 29 #include "chrome/common/pref_names.h"
30 #include "chrome/common/url_constants.h" 30 #include "chrome/common/url_constants.h"
31 #include "chrome/test/base/in_process_browser_test.h" 31 #include "chrome/test/base/in_process_browser_test.h"
32 #include "chrome/test/base/testing_profile.h" 32 #include "chrome/test/base/testing_profile.h"
33 #include "chrome/test/base/ui_test_utils.h" 33 #include "chrome/test/base/ui_test_utils.h"
34 #include "components/prefs/pref_service.h" 34 #include "components/prefs/pref_service.h"
35 #include "components/signin/core/common/profile_management_switches.h" 35 #include "components/signin/core/common/profile_management_switches.h"
36 #include "components/signin/core/common/signin_switches.h" 36 #include "components/signin/core/common/signin_switches.h"
37 #include "components/ui/zoom/page_zoom.h" 37 #include "components/zoom/page_zoom.h"
38 #include "components/ui/zoom/zoom_event_manager.h" 38 #include "components/zoom/zoom_event_manager.h"
39 #include "content/public/browser/host_zoom_map.h" 39 #include "content/public/browser/host_zoom_map.h"
40 #include "content/public/test/test_utils.h" 40 #include "content/public/test/test_utils.h"
41 #include "net/dns/mock_host_resolver.h" 41 #include "net/dns/mock_host_resolver.h"
42 #include "net/test/embedded_test_server/embedded_test_server.h" 42 #include "net/test/embedded_test_server/embedded_test_server.h"
43 #include "net/test/embedded_test_server/http_response.h" 43 #include "net/test/embedded_test_server/http_response.h"
44 #include "testing/gmock/include/gmock/gmock.h" 44 #include "testing/gmock/include/gmock/gmock.h"
45 #include "url/gurl.h" 45 #include "url/gurl.h"
46 46
47 using content::HostZoomMap; 47 using content::HostZoomMap;
48 48
49 namespace { 49 namespace {
50 50
51 class ZoomLevelChangeObserver { 51 class ZoomLevelChangeObserver {
52 public: 52 public:
53 explicit ZoomLevelChangeObserver(content::BrowserContext* context) 53 explicit ZoomLevelChangeObserver(content::BrowserContext* context)
54 : message_loop_runner_(new content::MessageLoopRunner) { 54 : message_loop_runner_(new content::MessageLoopRunner) {
55 subscription_ = ui_zoom::ZoomEventManager::GetForBrowserContext(context) 55 subscription_ = zoom::ZoomEventManager::GetForBrowserContext(context)
56 ->AddZoomLevelChangedCallback(base::Bind( 56 ->AddZoomLevelChangedCallback(base::Bind(
57 &ZoomLevelChangeObserver::OnZoomLevelChanged, 57 &ZoomLevelChangeObserver::OnZoomLevelChanged,
58 base::Unretained(this))); 58 base::Unretained(this)));
59 } 59 }
60 60
61 void BlockUntilZoomLevelForHostHasChanged(const std::string& host) { 61 void BlockUntilZoomLevelForHostHasChanged(const std::string& host) {
62 while (!std::count(changed_hosts_.begin(), changed_hosts_.end(), host)) { 62 while (!std::count(changed_hosts_.begin(), changed_hosts_.end(), host)) {
63 message_loop_runner_->Run(); 63 message_loop_runner_->Run();
64 message_loop_runner_ = new content::MessageLoopRunner; 64 message_loop_runner_ = new content::MessageLoopRunner;
65 } 65 }
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 289
290 GURL test_url2 = ConstructTestServerURL(kTestURLTemplate2); 290 GURL test_url2 = ConstructTestServerURL(kTestURLTemplate2);
291 ui_test_utils::NavigateToURLWithDisposition( 291 ui_test_utils::NavigateToURLWithDisposition(
292 browser(), test_url2, NEW_FOREGROUND_TAB, 292 browser(), test_url2, NEW_FOREGROUND_TAB,
293 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 293 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
294 EXPECT_TRUE( 294 EXPECT_TRUE(
295 content::ZoomValuesEqual(default_zoom_level, GetZoomLevel(test_url2))); 295 content::ZoomValuesEqual(default_zoom_level, GetZoomLevel(test_url2)));
296 296
297 content::WebContents* web_contents = 297 content::WebContents* web_contents =
298 browser()->tab_strip_model()->GetActiveWebContents(); 298 browser()->tab_strip_model()->GetActiveWebContents();
299 ui_zoom::PageZoom::Zoom(web_contents, content::PAGE_ZOOM_OUT); 299 zoom::PageZoom::Zoom(web_contents, content::PAGE_ZOOM_OUT);
300 observer.BlockUntilZoomLevelForHostHasChanged(test_url2.host()); 300 observer.BlockUntilZoomLevelForHostHasChanged(test_url2.host());
301 EXPECT_FALSE( 301 EXPECT_FALSE(
302 content::ZoomValuesEqual(default_zoom_level, GetZoomLevel(test_url2))); 302 content::ZoomValuesEqual(default_zoom_level, GetZoomLevel(test_url2)));
303 303
304 ui_zoom::PageZoom::Zoom(web_contents, content::PAGE_ZOOM_IN); 304 zoom::PageZoom::Zoom(web_contents, content::PAGE_ZOOM_IN);
305 observer.BlockUntilZoomLevelForHostHasChanged(test_url2.host()); 305 observer.BlockUntilZoomLevelForHostHasChanged(test_url2.host());
306 EXPECT_TRUE( 306 EXPECT_TRUE(
307 content::ZoomValuesEqual(default_zoom_level, GetZoomLevel(test_url2))); 307 content::ZoomValuesEqual(default_zoom_level, GetZoomLevel(test_url2)));
308 308
309 // Now both tabs should be at the default zoom level, so there should not be 309 // Now both tabs should be at the default zoom level, so there should not be
310 // any per-host values saved either to Pref, or internally in HostZoomMap. 310 // any per-host values saved either to Pref, or internally in HostZoomMap.
311 EXPECT_TRUE(GetHostsWithZoomLevels().empty()); 311 EXPECT_TRUE(GetHostsWithZoomLevels().empty());
312 EXPECT_TRUE(GetHostsWithZoomLevelsFromPrefs().empty()); 312 EXPECT_TRUE(GetHostsWithZoomLevelsFromPrefs().empty());
313 } 313 }
314 314
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 ZoomLevelChangeObserver observer(browser()->profile()); 409 ZoomLevelChangeObserver observer(browser()->profile());
410 410
411 web_contents->SetPageScale(1.5); 411 web_contents->SetPageScale(1.5);
412 observer.BlockUntilZoomLevelForHostHasChanged(test_host); 412 observer.BlockUntilZoomLevelForHostHasChanged(test_host);
413 EXPECT_FALSE(content::HostZoomMap::PageScaleFactorIsOne(web_contents)); 413 EXPECT_FALSE(content::HostZoomMap::PageScaleFactorIsOne(web_contents));
414 414
415 web_contents->SetPageScale(1.f); 415 web_contents->SetPageScale(1.f);
416 observer.BlockUntilZoomLevelForHostHasChanged(test_host); 416 observer.BlockUntilZoomLevelForHostHasChanged(test_host);
417 EXPECT_TRUE(content::HostZoomMap::PageScaleFactorIsOne(web_contents)); 417 EXPECT_TRUE(content::HostZoomMap::PageScaleFactorIsOne(web_contents));
418 } 418 }
OLDNEW
« no previous file with comments | « chrome/browser/plugins/plugin_power_saver_browsertest.cc ('k') | chrome/browser/profiles/off_the_record_profile_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698