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 "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 23 matching lines...) Expand all Loading... | |
34 const gfx::Rect& window_bounds, | 34 const gfx::Rect& window_bounds, |
35 const gfx::Rect& content_bounds, | 35 const gfx::Rect& content_bounds, |
36 const blink::WebScreenInfo& screen_info, | 36 const blink::WebScreenInfo& screen_info, |
37 const std::string& version, | 37 const std::string& version, |
38 const std::string& charset, | 38 const std::string& charset, |
39 const std::string& accept_languages, | 39 const std::string& accept_languages, |
40 const base::Time& install_time, | 40 const base::Time& install_time, |
41 const std::string& app_locale, | 41 const std::string& app_locale, |
42 const std::string& user_agent, | 42 const std::string& user_agent, |
43 const base::TimeDelta& timeout, | 43 const base::TimeDelta& timeout, |
44 const base::Callback<void(scoped_ptr<Fingerprint>)>& callback); | 44 const base::Callback<void(std::unique_ptr<Fingerprint>)>& callback); |
Mathieu
2016/04/04 13:36:16
Is it a pattern not to include <memory> for tests?
vabr (Chromium)
2016/04/04 14:29:04
I believe this is a good place to have the #includ
| |
45 | 45 |
46 } // namespace internal | 46 } // namespace internal |
47 | 47 |
48 // Constants that are passed verbatim to the fingerprinter code and should be | 48 // Constants that are passed verbatim to the fingerprinter code and should be |
49 // serialized into the resulting protocol buffer. | 49 // serialized into the resulting protocol buffer. |
50 const uint64_t kObfuscatedGaiaId = UINT64_C(16571487432910023183); | 50 const uint64_t kObfuscatedGaiaId = UINT64_C(16571487432910023183); |
51 const char kCharset[] = "UTF-8"; | 51 const char kCharset[] = "UTF-8"; |
52 const char kAcceptLanguages[] = "en-US,en"; | 52 const char kAcceptLanguages[] = "en-US,en"; |
53 const int kScreenColorDepth = 53; | 53 const int kScreenColorDepth = 53; |
54 const char kLocale[] = "en-GB"; | 54 const char kLocale[] = "en-GB"; |
55 const char kUserAgent[] = "TestUserAgent"; | 55 const char kUserAgent[] = "TestUserAgent"; |
56 | 56 |
57 // Geolocation constants that are passed verbatim to the fingerprinter code and | 57 // Geolocation constants that are passed verbatim to the fingerprinter code and |
58 // should be serialized into the resulting protocol buffer. | 58 // should be serialized into the resulting protocol buffer. |
59 const double kLatitude = -42.0; | 59 const double kLatitude = -42.0; |
60 const double kLongitude = 17.3; | 60 const double kLongitude = 17.3; |
61 const double kAltitude = 123.4; | 61 const double kAltitude = 123.4; |
62 const double kAccuracy = 73.7; | 62 const double kAccuracy = 73.7; |
63 const int kGeolocationTime = 87; | 63 const int kGeolocationTime = 87; |
64 | 64 |
65 class AutofillRiskFingerprintTest : public content::ContentBrowserTest { | 65 class AutofillRiskFingerprintTest : public content::ContentBrowserTest { |
66 public: | 66 public: |
67 AutofillRiskFingerprintTest() | 67 AutofillRiskFingerprintTest() |
68 : window_bounds_(2, 3, 5, 7), | 68 : window_bounds_(2, 3, 5, 7), |
69 content_bounds_(11, 13, 17, 37), | 69 content_bounds_(11, 13, 17, 37), |
70 screen_bounds_(0, 0, 101, 71), | 70 screen_bounds_(0, 0, 101, 71), |
71 available_screen_bounds_(0, 11, 101, 60), | 71 available_screen_bounds_(0, 11, 101, 60), |
72 unavailable_screen_bounds_(0, 0, 101, 11) {} | 72 unavailable_screen_bounds_(0, 0, 101, 11) {} |
73 | 73 |
74 void GetFingerprintTestCallback(scoped_ptr<Fingerprint> fingerprint) { | 74 void GetFingerprintTestCallback(std::unique_ptr<Fingerprint> fingerprint) { |
75 // Verify that all fields Chrome can fill have been filled. | 75 // Verify that all fields Chrome can fill have been filled. |
76 ASSERT_TRUE(fingerprint->has_machine_characteristics()); | 76 ASSERT_TRUE(fingerprint->has_machine_characteristics()); |
77 const Fingerprint::MachineCharacteristics& machine = | 77 const Fingerprint::MachineCharacteristics& machine = |
78 fingerprint->machine_characteristics(); | 78 fingerprint->machine_characteristics(); |
79 EXPECT_TRUE(machine.has_operating_system_build()); | 79 EXPECT_TRUE(machine.has_operating_system_build()); |
80 EXPECT_TRUE(machine.has_browser_install_time_hours()); | 80 EXPECT_TRUE(machine.has_browser_install_time_hours()); |
81 EXPECT_GT(machine.font_size(), 0); | 81 EXPECT_GT(machine.font_size(), 0); |
82 | 82 |
83 // TODO(isherman): http://crbug.com/358548 and EXPECT_EQ. | 83 // TODO(isherman): http://crbug.com/358548 and EXPECT_EQ. |
84 EXPECT_GE(machine.plugin_size(), 0); | 84 EXPECT_GE(machine.plugin_size(), 0); |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
214 base::TimeDelta::FromDays(1), // Ought to be longer than any test run. | 214 base::TimeDelta::FromDays(1), // Ought to be longer than any test run. |
215 base::Bind(&AutofillRiskFingerprintTest::GetFingerprintTestCallback, | 215 base::Bind(&AutofillRiskFingerprintTest::GetFingerprintTestCallback, |
216 base::Unretained(this))); | 216 base::Unretained(this))); |
217 | 217 |
218 // Wait for the callback to be called. | 218 // Wait for the callback to be called. |
219 message_loop_.Run(); | 219 message_loop_.Run(); |
220 } | 220 } |
221 | 221 |
222 } // namespace risk | 222 } // namespace risk |
223 } // namespace autofill | 223 } // namespace autofill |
OLD | NEW |