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

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

Issue 847703003: Refactor to move chrome_page_zoom functions to components/ui/zoom. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Mac compile. Created 5 years, 11 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 "content/public/browser/host_zoom_map.h" 5 #include "content/public/browser/host_zoom_map.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
13 #include "base/files/file_util.h" 13 #include "base/files/file_util.h"
14 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
15 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
16 #include "base/path_service.h" 16 #include "base/path_service.h"
17 #include "base/prefs/pref_service.h" 17 #include "base/prefs/pref_service.h"
18 #include "base/strings/stringprintf.h" 18 #include "base/strings/stringprintf.h"
19 #include "base/values.h" 19 #include "base/values.h"
20 #include "chrome/browser/chrome_page_zoom.h"
21 #include "chrome/browser/profiles/profile.h" 20 #include "chrome/browser/profiles/profile.h"
22 #include "chrome/browser/profiles/profile_impl.h" 21 #include "chrome/browser/profiles/profile_impl.h"
23 #include "chrome/browser/ui/browser.h" 22 #include "chrome/browser/ui/browser.h"
24 #include "chrome/browser/ui/tabs/tab_strip_model.h" 23 #include "chrome/browser/ui/tabs/tab_strip_model.h"
25 #include "chrome/browser/ui/zoom/chrome_zoom_level_prefs.h" 24 #include "chrome/browser/ui/zoom/chrome_zoom_level_prefs.h"
26 #include "chrome/common/chrome_constants.h" 25 #include "chrome/common/chrome_constants.h"
27 #include "chrome/common/chrome_paths.h" 26 #include "chrome/common/chrome_paths.h"
28 #include "chrome/common/pref_names.h" 27 #include "chrome/common/pref_names.h"
29 #include "chrome/common/url_constants.h" 28 #include "chrome/common/url_constants.h"
30 #include "chrome/test/base/in_process_browser_test.h" 29 #include "chrome/test/base/in_process_browser_test.h"
31 #include "chrome/test/base/testing_profile.h" 30 #include "chrome/test/base/testing_profile.h"
32 #include "chrome/test/base/ui_test_utils.h" 31 #include "chrome/test/base/ui_test_utils.h"
33 #include "components/signin/core/common/profile_management_switches.h" 32 #include "components/signin/core/common/profile_management_switches.h"
33 #include "components/ui/zoom/page_zoom.h"
34 #include "components/ui/zoom/zoom_event_manager.h" 34 #include "components/ui/zoom/zoom_event_manager.h"
35 #include "content/public/test/test_utils.h" 35 #include "content/public/test/test_utils.h"
36 #include "net/dns/mock_host_resolver.h" 36 #include "net/dns/mock_host_resolver.h"
37 #include "net/test/embedded_test_server/embedded_test_server.h" 37 #include "net/test/embedded_test_server/embedded_test_server.h"
38 #include "net/test/embedded_test_server/http_response.h" 38 #include "net/test/embedded_test_server/http_response.h"
39 #include "testing/gmock/include/gmock/gmock.h" 39 #include "testing/gmock/include/gmock/gmock.h"
40 #include "url/gurl.h" 40 #include "url/gurl.h"
41 41
42 using content::HostZoomMap; 42 using content::HostZoomMap;
43 43
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 295
296 GURL test_url2 = ConstructTestServerURL(kTestURLTemplate2); 296 GURL test_url2 = ConstructTestServerURL(kTestURLTemplate2);
297 ui_test_utils::NavigateToURLWithDisposition( 297 ui_test_utils::NavigateToURLWithDisposition(
298 browser(), test_url2, NEW_FOREGROUND_TAB, 298 browser(), test_url2, NEW_FOREGROUND_TAB,
299 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 299 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
300 EXPECT_TRUE( 300 EXPECT_TRUE(
301 content::ZoomValuesEqual(default_zoom_level, GetZoomLevel(test_url2))); 301 content::ZoomValuesEqual(default_zoom_level, GetZoomLevel(test_url2)));
302 302
303 content::WebContents* web_contents = 303 content::WebContents* web_contents =
304 browser()->tab_strip_model()->GetActiveWebContents(); 304 browser()->tab_strip_model()->GetActiveWebContents();
305 chrome_page_zoom::Zoom(web_contents, content::PAGE_ZOOM_OUT); 305 ui_zoom::PageZoom::Zoom(web_contents, content::PAGE_ZOOM_OUT);
306 observer.BlockUntilZoomLevelForHostHasChanged(test_url2.host()); 306 observer.BlockUntilZoomLevelForHostHasChanged(test_url2.host());
307 EXPECT_FALSE( 307 EXPECT_FALSE(
308 content::ZoomValuesEqual(default_zoom_level, GetZoomLevel(test_url2))); 308 content::ZoomValuesEqual(default_zoom_level, GetZoomLevel(test_url2)));
309 309
310 chrome_page_zoom::Zoom(web_contents, content::PAGE_ZOOM_IN); 310 ui_zoom::PageZoom::Zoom(web_contents, content::PAGE_ZOOM_IN);
311 observer.BlockUntilZoomLevelForHostHasChanged(test_url2.host()); 311 observer.BlockUntilZoomLevelForHostHasChanged(test_url2.host());
312 EXPECT_TRUE( 312 EXPECT_TRUE(
313 content::ZoomValuesEqual(default_zoom_level, GetZoomLevel(test_url2))); 313 content::ZoomValuesEqual(default_zoom_level, GetZoomLevel(test_url2)));
314 314
315 // Now both tabs should be at the default zoom level, so there should not be 315 // Now both tabs should be at the default zoom level, so there should not be
316 // any per-host values saved either to Pref, or internally in HostZoomMap. 316 // any per-host values saved either to Pref, or internally in HostZoomMap.
317 EXPECT_TRUE(GetHostsWithZoomLevels().empty()); 317 EXPECT_TRUE(GetHostsWithZoomLevels().empty());
318 EXPECT_TRUE(GetHostsWithZoomLevelsFromPrefs().empty()); 318 EXPECT_TRUE(GetHostsWithZoomLevelsFromPrefs().empty());
319 } 319 }
320 320
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 parent_zoom_map->SetZoomLevelForHost(host, zoom_level_40); 458 parent_zoom_map->SetZoomLevelForHost(host, zoom_level_40);
459 ASSERT_EQ( 459 ASSERT_EQ(
460 parent_zoom_map->GetZoomLevelForHostAndScheme("http", host), 460 parent_zoom_map->GetZoomLevelForHostAndScheme("http", host),
461 zoom_level_40); 461 zoom_level_40);
462 462
463 EXPECT_EQ(parent_zoom_map->GetZoomLevelForHostAndScheme("http", host), 463 EXPECT_EQ(parent_zoom_map->GetZoomLevelForHostAndScheme("http", host),
464 child_zoom_map->GetZoomLevelForHostAndScheme("http", host)) << 464 child_zoom_map->GetZoomLevelForHostAndScheme("http", host)) <<
465 "Parent change should propagate to child."; 465 "Parent change should propagate to child.";
466 base::RunLoop().RunUntilIdle(); 466 base::RunLoop().RunUntilIdle();
467 } 467 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698