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 "components/autofill/content/browser/risk/fingerprint.h" | 5 #include "components/autofill/content/browser/risk/fingerprint.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
14 #include "components/autofill/content/browser/risk/proto/fingerprint.pb.h" | 14 #include "components/autofill/content/browser/risk/proto/fingerprint.pb.h" |
15 #include "content/public/browser/geolocation_provider.h" | |
16 #include "content/public/browser/gpu_data_manager.h" | 15 #include "content/public/browser/gpu_data_manager.h" |
17 #include "content/public/common/geoposition.h" | |
18 #include "content/public/test/content_browser_test.h" | 16 #include "content/public/test/content_browser_test.h" |
19 #include "content/public/test/test_utils.h" | 17 #include "content/public/test/test_utils.h" |
| 18 #include "device/geolocation/geolocation_provider.h" |
| 19 #include "device/geolocation/geoposition.h" |
20 #include "testing/gmock/include/gmock/gmock.h" | 20 #include "testing/gmock/include/gmock/gmock.h" |
21 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
22 #include "third_party/WebKit/public/platform/WebRect.h" | 22 #include "third_party/WebKit/public/platform/WebRect.h" |
23 #include "third_party/WebKit/public/platform/WebScreenInfo.h" | 23 #include "third_party/WebKit/public/platform/WebScreenInfo.h" |
24 #include "ui/gfx/geometry/rect.h" | 24 #include "ui/gfx/geometry/rect.h" |
25 | 25 |
26 using testing::ElementsAre; | 26 using testing::ElementsAre; |
27 | 27 |
28 namespace autofill { | 28 namespace autofill { |
29 namespace risk { | 29 namespace risk { |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 const gfx::Rect screen_bounds_; | 179 const gfx::Rect screen_bounds_; |
180 const gfx::Rect available_screen_bounds_; | 180 const gfx::Rect available_screen_bounds_; |
181 const gfx::Rect unavailable_screen_bounds_; | 181 const gfx::Rect unavailable_screen_bounds_; |
182 | 182 |
183 // A message loop to block on the asynchronous loading of the fingerprint. | 183 // A message loop to block on the asynchronous loading of the fingerprint. |
184 base::MessageLoopForUI message_loop_; | 184 base::MessageLoopForUI message_loop_; |
185 }; | 185 }; |
186 | 186 |
187 // Test that getting a fingerprint works on some basic level. | 187 // Test that getting a fingerprint works on some basic level. |
188 IN_PROC_BROWSER_TEST_F(AutofillRiskFingerprintTest, GetFingerprint) { | 188 IN_PROC_BROWSER_TEST_F(AutofillRiskFingerprintTest, GetFingerprint) { |
189 content::Geoposition position; | 189 device::Geoposition position; |
190 position.latitude = kLatitude; | 190 position.latitude = kLatitude; |
191 position.longitude = kLongitude; | 191 position.longitude = kLongitude; |
192 position.altitude = kAltitude; | 192 position.altitude = kAltitude; |
193 position.accuracy = kAccuracy; | 193 position.accuracy = kAccuracy; |
194 position.timestamp = | 194 position.timestamp = |
195 base::Time::UnixEpoch() + | 195 base::Time::UnixEpoch() + |
196 base::TimeDelta::FromMilliseconds(kGeolocationTime); | 196 base::TimeDelta::FromMilliseconds(kGeolocationTime); |
197 content::GeolocationProvider::GetInstance()->OverrideLocationForTesting( | 197 device::GeolocationProvider::GetInstance()->OverrideLocationForTesting( |
198 position); | 198 position); |
199 | 199 |
200 blink::WebScreenInfo screen_info; | 200 blink::WebScreenInfo screen_info; |
201 screen_info.depth = kScreenColorDepth; | 201 screen_info.depth = kScreenColorDepth; |
202 screen_info.rect = blink::WebRect(screen_bounds_); | 202 screen_info.rect = blink::WebRect(screen_bounds_); |
203 screen_info.availableRect = blink::WebRect(available_screen_bounds_); | 203 screen_info.availableRect = blink::WebRect(available_screen_bounds_); |
204 | 204 |
205 internal::GetFingerprintInternal( | 205 internal::GetFingerprintInternal( |
206 kObfuscatedGaiaId, window_bounds_, content_bounds_, screen_info, | 206 kObfuscatedGaiaId, window_bounds_, content_bounds_, screen_info, |
207 "25.0.0.123", kCharset, kAcceptLanguages, base::Time::Now(), kLocale, | 207 "25.0.0.123", kCharset, kAcceptLanguages, base::Time::Now(), kLocale, |
208 kUserAgent, | 208 kUserAgent, |
209 base::TimeDelta::FromDays(1), // Ought to be longer than any test run. | 209 base::TimeDelta::FromDays(1), // Ought to be longer than any test run. |
210 base::Bind(&AutofillRiskFingerprintTest::GetFingerprintTestCallback, | 210 base::Bind(&AutofillRiskFingerprintTest::GetFingerprintTestCallback, |
211 base::Unretained(this))); | 211 base::Unretained(this))); |
212 | 212 |
213 // Wait for the callback to be called. | 213 // Wait for the callback to be called. |
214 message_loop_.Run(); | 214 message_loop_.Run(); |
215 } | 215 } |
216 | 216 |
217 } // namespace risk | 217 } // namespace risk |
218 } // namespace autofill | 218 } // namespace autofill |
OLD | NEW |