| 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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 } | 124 } |
| 125 | 125 |
| 126 private: | 126 private: |
| 127 scoped_ptr<net::test_server::HttpResponse> HandleRequest( | 127 scoped_ptr<net::test_server::HttpResponse> HandleRequest( |
| 128 const net::test_server::HttpRequest& request) { | 128 const net::test_server::HttpRequest& request) { |
| 129 return scoped_ptr<net::test_server::HttpResponse>( | 129 return scoped_ptr<net::test_server::HttpResponse>( |
| 130 new net::test_server::BasicHttpResponse); | 130 new net::test_server::BasicHttpResponse); |
| 131 } | 131 } |
| 132 | 132 |
| 133 // BrowserTestBase: | 133 // BrowserTestBase: |
| 134 virtual void SetUpOnMainThread() override { | 134 void SetUpOnMainThread() override { |
| 135 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 135 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| 136 embedded_test_server()->RegisterRequestHandler(base::Bind( | 136 embedded_test_server()->RegisterRequestHandler(base::Bind( |
| 137 &HostZoomMapBrowserTest::HandleRequest, base::Unretained(this))); | 137 &HostZoomMapBrowserTest::HandleRequest, base::Unretained(this))); |
| 138 host_resolver()->AddRule("*", "127.0.0.1"); | 138 host_resolver()->AddRule("*", "127.0.0.1"); |
| 139 } | 139 } |
| 140 | 140 |
| 141 DISALLOW_COPY_AND_ASSIGN(HostZoomMapBrowserTest); | 141 DISALLOW_COPY_AND_ASSIGN(HostZoomMapBrowserTest); |
| 142 }; | 142 }; |
| 143 | 143 |
| 144 #define PARTITION_KEY_PLACEHOLDER "NNN" | 144 #define PARTITION_KEY_PLACEHOLDER "NNN" |
| 145 | 145 |
| 146 class HostZoomMapBrowserTestWithPrefs : public HostZoomMapBrowserTest { | 146 class HostZoomMapBrowserTestWithPrefs : public HostZoomMapBrowserTest { |
| 147 public: | 147 public: |
| 148 explicit HostZoomMapBrowserTestWithPrefs(const std::string& prefs_data) | 148 explicit HostZoomMapBrowserTestWithPrefs(const std::string& prefs_data) |
| 149 : prefs_data_(prefs_data) {} | 149 : prefs_data_(prefs_data) {} |
| 150 | 150 |
| 151 private: | 151 private: |
| 152 // InProcessBrowserTest: | 152 // InProcessBrowserTest: |
| 153 virtual bool SetUpUserDataDirectory() override { | 153 bool SetUpUserDataDirectory() override { |
| 154 std::replace(prefs_data_.begin(), prefs_data_.end(), '\'', '\"'); | 154 std::replace(prefs_data_.begin(), prefs_data_.end(), '\'', '\"'); |
| 155 // It seems the hash functions on different platforms can return different | 155 // It seems the hash functions on different platforms can return different |
| 156 // values for the same input, so make sure we test with the hash appropriate | 156 // values for the same input, so make sure we test with the hash appropriate |
| 157 // for the platform. | 157 // for the platform. |
| 158 std::string hash_string = | 158 std::string hash_string = |
| 159 chrome::ChromeZoomLevelPrefs::GetHashForTesting(base::FilePath()); | 159 chrome::ChromeZoomLevelPrefs::GetHashForTesting(base::FilePath()); |
| 160 std::string partition_key_placeholder(PARTITION_KEY_PLACEHOLDER); | 160 std::string partition_key_placeholder(PARTITION_KEY_PLACEHOLDER); |
| 161 size_t start_index; | 161 size_t start_index; |
| 162 while ((start_index = prefs_data_.find(partition_key_placeholder)) != | 162 while ((start_index = prefs_data_.find(partition_key_placeholder)) != |
| 163 std::string::npos) { | 163 std::string::npos) { |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 | 334 |
| 335 // Change the default zoom level and observe. | 335 // Change the default zoom level and observe. |
| 336 SetDefaultZoomLevel(kNewDefaultZoomLevel); | 336 SetDefaultZoomLevel(kNewDefaultZoomLevel); |
| 337 observer.BlockUntilZoomLevelForHostHasChanged(test_url.host()); | 337 observer.BlockUntilZoomLevelForHostHasChanged(test_url.host()); |
| 338 EXPECT_TRUE( | 338 EXPECT_TRUE( |
| 339 content::ZoomValuesEqual(kNewDefaultZoomLevel, GetZoomLevel(test_url))); | 339 content::ZoomValuesEqual(kNewDefaultZoomLevel, GetZoomLevel(test_url))); |
| 340 EXPECT_EQ(kNewDefaultZoomLevel, zoom_level_prefs->GetDefaultZoomLevelPref()); | 340 EXPECT_EQ(kNewDefaultZoomLevel, zoom_level_prefs->GetDefaultZoomLevelPref()); |
| 341 EXPECT_EQ(0.0, profile_prefs->GetDouble(prefs::kDefaultZoomLevelDeprecated)); | 341 EXPECT_EQ(0.0, profile_prefs->GetDouble(prefs::kDefaultZoomLevelDeprecated)); |
| 342 } | 342 } |
| 343 | 343 |
| OLD | NEW |