OLD | NEW |
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 |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 } | 120 } |
121 | 121 |
122 private: | 122 private: |
123 scoped_ptr<net::test_server::HttpResponse> HandleRequest( | 123 scoped_ptr<net::test_server::HttpResponse> HandleRequest( |
124 const net::test_server::HttpRequest& request) { | 124 const net::test_server::HttpRequest& request) { |
125 return scoped_ptr<net::test_server::HttpResponse>( | 125 return scoped_ptr<net::test_server::HttpResponse>( |
126 new net::test_server::BasicHttpResponse); | 126 new net::test_server::BasicHttpResponse); |
127 } | 127 } |
128 | 128 |
129 // BrowserTestBase: | 129 // BrowserTestBase: |
130 virtual void SetUpOnMainThread() OVERRIDE { | 130 virtual void SetUpOnMainThread() override { |
131 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 131 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
132 embedded_test_server()->RegisterRequestHandler(base::Bind( | 132 embedded_test_server()->RegisterRequestHandler(base::Bind( |
133 &HostZoomMapBrowserTest::HandleRequest, base::Unretained(this))); | 133 &HostZoomMapBrowserTest::HandleRequest, base::Unretained(this))); |
134 host_resolver()->AddRule("*", "127.0.0.1"); | 134 host_resolver()->AddRule("*", "127.0.0.1"); |
135 } | 135 } |
136 | 136 |
137 DISALLOW_COPY_AND_ASSIGN(HostZoomMapBrowserTest); | 137 DISALLOW_COPY_AND_ASSIGN(HostZoomMapBrowserTest); |
138 }; | 138 }; |
139 | 139 |
140 class HostZoomMapSanitizationBrowserTest : public HostZoomMapBrowserTest { | 140 class HostZoomMapSanitizationBrowserTest : public HostZoomMapBrowserTest { |
141 public: | 141 public: |
142 HostZoomMapSanitizationBrowserTest() {} | 142 HostZoomMapSanitizationBrowserTest() {} |
143 | 143 |
144 private: | 144 private: |
145 // InProcessBrowserTest: | 145 // InProcessBrowserTest: |
146 virtual bool SetUpUserDataDirectory() OVERRIDE { | 146 virtual bool SetUpUserDataDirectory() override { |
147 // Zoom-related preferences demonstrating the two problems that could be | 147 // Zoom-related preferences demonstrating the two problems that could be |
148 // caused by the bug. They incorrectly contain a per-host zoom level for the | 148 // caused by the bug. They incorrectly contain a per-host zoom level for the |
149 // empty host; and a value for 'host1' that only differs from the default by | 149 // empty host; and a value for 'host1' that only differs from the default by |
150 // epsilon. Neither should have been persisted. | 150 // epsilon. Neither should have been persisted. |
151 const char kBrokenPrefs[] = | 151 const char kBrokenPrefs[] = |
152 "{'profile': {" | 152 "{'profile': {" |
153 " 'default_zoom_level': 1.2," | 153 " 'default_zoom_level': 1.2," |
154 " 'per_host_zoom_levels': {'': 1.1, 'host1': 1.20001, 'host2': 1.3}" | 154 " 'per_host_zoom_levels': {'': 1.1, 'host1': 1.20001, 'host2': 1.3}" |
155 "}}"; | 155 "}}"; |
156 std::string broken_prefs(kBrokenPrefs); | 156 std::string broken_prefs(kBrokenPrefs); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 // any per-host values saved either to Pref, or internally in HostZoomMap. | 209 // any per-host values saved either to Pref, or internally in HostZoomMap. |
210 EXPECT_TRUE(GetHostsWithZoomLevels().empty()); | 210 EXPECT_TRUE(GetHostsWithZoomLevels().empty()); |
211 EXPECT_TRUE(GetHostsWithZoomLevelsFromPrefs().empty()); | 211 EXPECT_TRUE(GetHostsWithZoomLevelsFromPrefs().empty()); |
212 } | 212 } |
213 | 213 |
214 // Test that garbage data from crbug.com/364399 is cleared up on startup. | 214 // Test that garbage data from crbug.com/364399 is cleared up on startup. |
215 IN_PROC_BROWSER_TEST_F(HostZoomMapSanitizationBrowserTest, ClearOnStartup) { | 215 IN_PROC_BROWSER_TEST_F(HostZoomMapSanitizationBrowserTest, ClearOnStartup) { |
216 EXPECT_THAT(GetHostsWithZoomLevels(), testing::ElementsAre("host2")); | 216 EXPECT_THAT(GetHostsWithZoomLevels(), testing::ElementsAre("host2")); |
217 EXPECT_THAT(GetHostsWithZoomLevelsFromPrefs(), testing::ElementsAre("host2")); | 217 EXPECT_THAT(GetHostsWithZoomLevelsFromPrefs(), testing::ElementsAre("host2")); |
218 } | 218 } |
OLD | NEW |