| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browser/risk/fingerprint.h" | 5 #include "components/autofill/browser/risk/fingerprint.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/port.h" | 9 #include "base/port.h" |
| 10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| 11 #include "chrome/test/base/in_process_browser_test.h" | 11 #include "chrome/test/base/in_process_browser_test.h" |
| 12 #include "components/autofill/browser/risk/proto/fingerprint.pb.h" | 12 #include "components/autofill/browser/risk/proto/fingerprint.pb.h" |
| 13 #include "content/public/browser/geolocation_provider.h" | 13 #include "content/public/browser/geolocation_provider.h" |
| 14 #include "content/public/common/geoposition.h" | 14 #include "content/public/common/geoposition.h" |
| 15 #include "content/public/test/test_utils.h" | 15 #include "content/public/test/test_utils.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 17 #include "third_party/WebKit/Source/Platform/chromium/public/WebRect.h" | 17 #include "third_party/WebKit/Source/Platform/chromium/public/WebRect.h" |
| 18 #include "third_party/WebKit/Source/Platform/chromium/public/WebScreenInfo.h" | 18 #include "third_party/WebKit/Source/Platform/chromium/public/WebScreenInfo.h" |
| 19 #include "ui/gfx/rect.h" | 19 #include "ui/gfx/rect.h" |
| 20 | 20 |
| 21 namespace autofill { | 21 namespace autofill { |
| 22 namespace risk { | 22 namespace risk { |
| 23 | 23 |
| 24 const int64 kGaiaId = GG_INT64_C(99194853094755497); | 24 const uint64 kObfuscatedGaiaId = GG_UINT64_C(16571487432910023183); |
| 25 const char kCharset[] = "UTF-8"; | 25 const char kCharset[] = "UTF-8"; |
| 26 const char kAcceptLanguages[] = "en-US,en"; | 26 const char kAcceptLanguages[] = "en-US,en"; |
| 27 const int kScreenColorDepth = 53; | 27 const int kScreenColorDepth = 53; |
| 28 | 28 |
| 29 const double kLatitude = -42.0; | 29 const double kLatitude = -42.0; |
| 30 const double kLongitude = 17.3; | 30 const double kLongitude = 17.3; |
| 31 const double kAltitude = 123.4; | 31 const double kAltitude = 123.4; |
| 32 const double kAccuracy = 73.7; | 32 const double kAccuracy = 73.7; |
| 33 const int kGeolocationTime = 87; | 33 const int kGeolocationTime = 87; |
| 34 | 34 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 const Fingerprint_UserCharacteristics_Location& location = | 91 const Fingerprint_UserCharacteristics_Location& location = |
| 92 user_characteristics.location(); | 92 user_characteristics.location(); |
| 93 ASSERT_TRUE(location.has_altitude()); | 93 ASSERT_TRUE(location.has_altitude()); |
| 94 ASSERT_TRUE(location.has_latitude()); | 94 ASSERT_TRUE(location.has_latitude()); |
| 95 ASSERT_TRUE(location.has_longitude()); | 95 ASSERT_TRUE(location.has_longitude()); |
| 96 ASSERT_TRUE(location.has_accuracy()); | 96 ASSERT_TRUE(location.has_accuracy()); |
| 97 ASSERT_TRUE(location.has_time_in_ms()); | 97 ASSERT_TRUE(location.has_time_in_ms()); |
| 98 | 98 |
| 99 ASSERT_TRUE(fingerprint->has_metadata()); | 99 ASSERT_TRUE(fingerprint->has_metadata()); |
| 100 ASSERT_TRUE(fingerprint->metadata().has_timestamp_ms()); | 100 ASSERT_TRUE(fingerprint->metadata().has_timestamp_ms()); |
| 101 ASSERT_TRUE(fingerprint->metadata().has_gaia_id()); | 101 ASSERT_TRUE(fingerprint->metadata().has_obfuscated_gaia_id()); |
| 102 ASSERT_TRUE(fingerprint->metadata().has_fingerprinter_version()); | 102 ASSERT_TRUE(fingerprint->metadata().has_fingerprinter_version()); |
| 103 | 103 |
| 104 // Some values have exact known (mocked out) values: | 104 // Some values have exact known (mocked out) values: |
| 105 ASSERT_EQ(2, machine.requested_language_size()); | 105 ASSERT_EQ(2, machine.requested_language_size()); |
| 106 EXPECT_EQ("en-US", machine.requested_language(0)); | 106 EXPECT_EQ("en-US", machine.requested_language(0)); |
| 107 EXPECT_EQ("en", machine.requested_language(1)); | 107 EXPECT_EQ("en", machine.requested_language(1)); |
| 108 EXPECT_EQ(kCharset, machine.charset()); | 108 EXPECT_EQ(kCharset, machine.charset()); |
| 109 EXPECT_EQ(kScreenColorDepth, machine.screen_color_depth()); | 109 EXPECT_EQ(kScreenColorDepth, machine.screen_color_depth()); |
| 110 EXPECT_EQ(kUnavailableScreenBounds.width(), | 110 EXPECT_EQ(kUnavailableScreenBounds.width(), |
| 111 machine.unavailable_screen_size().width()); | 111 machine.unavailable_screen_size().width()); |
| 112 EXPECT_EQ(kUnavailableScreenBounds.height(), | 112 EXPECT_EQ(kUnavailableScreenBounds.height(), |
| 113 machine.unavailable_screen_size().height()); | 113 machine.unavailable_screen_size().height()); |
| 114 EXPECT_EQ( | 114 EXPECT_EQ( |
| 115 Fingerprint_MachineCharacteristics_BrowserFeature_FEATURE_AUTOCHECKOUT, | 115 Fingerprint_MachineCharacteristics_BrowserFeature_FEATURE_AUTOCHECKOUT, |
| 116 machine.browser_feature()); | 116 machine.browser_feature()); |
| 117 EXPECT_EQ(kContentBounds.width(), | 117 EXPECT_EQ(kContentBounds.width(), |
| 118 transient_state.inner_window_size().width()); | 118 transient_state.inner_window_size().width()); |
| 119 EXPECT_EQ(kContentBounds.height(), | 119 EXPECT_EQ(kContentBounds.height(), |
| 120 transient_state.inner_window_size().height()); | 120 transient_state.inner_window_size().height()); |
| 121 EXPECT_EQ(kWindowBounds.width(), | 121 EXPECT_EQ(kWindowBounds.width(), |
| 122 transient_state.outer_window_size().width()); | 122 transient_state.outer_window_size().width()); |
| 123 EXPECT_EQ(kWindowBounds.height(), | 123 EXPECT_EQ(kWindowBounds.height(), |
| 124 transient_state.outer_window_size().height()); | 124 transient_state.outer_window_size().height()); |
| 125 EXPECT_EQ(kGaiaId, fingerprint->metadata().gaia_id()); | 125 EXPECT_EQ(kObfuscatedGaiaId, fingerprint->metadata().obfuscated_gaia_id()); |
| 126 EXPECT_EQ(kAltitude, location.altitude()); | 126 EXPECT_EQ(kAltitude, location.altitude()); |
| 127 EXPECT_EQ(kLatitude, location.latitude()); | 127 EXPECT_EQ(kLatitude, location.latitude()); |
| 128 EXPECT_EQ(kLongitude, location.longitude()); | 128 EXPECT_EQ(kLongitude, location.longitude()); |
| 129 EXPECT_EQ(kAccuracy, location.accuracy()); | 129 EXPECT_EQ(kAccuracy, location.accuracy()); |
| 130 EXPECT_EQ(kGeolocationTime, location.time_in_ms()); | 130 EXPECT_EQ(kGeolocationTime, location.time_in_ms()); |
| 131 | 131 |
| 132 message_loop_.Quit(); | 132 message_loop_.Quit(); |
| 133 } | 133 } |
| 134 | 134 |
| 135 protected: | 135 protected: |
| (...skipping 26 matching lines...) Expand all Loading... |
| 162 content::GeolocationProvider::OverrideLocationForTesting( | 162 content::GeolocationProvider::OverrideLocationForTesting( |
| 163 position, runner->QuitClosure()); | 163 position, runner->QuitClosure()); |
| 164 runner->Run(); | 164 runner->Run(); |
| 165 | 165 |
| 166 WebKit::WebScreenInfo screen_info; | 166 WebKit::WebScreenInfo screen_info; |
| 167 screen_info.depth = kScreenColorDepth; | 167 screen_info.depth = kScreenColorDepth; |
| 168 screen_info.rect = WebKit::WebRect(kScreenBounds); | 168 screen_info.rect = WebKit::WebRect(kScreenBounds); |
| 169 screen_info.availableRect = WebKit::WebRect(kAvailableScreenBounds); | 169 screen_info.availableRect = WebKit::WebRect(kAvailableScreenBounds); |
| 170 | 170 |
| 171 internal::GetFingerprintInternal( | 171 internal::GetFingerprintInternal( |
| 172 kGaiaId, kWindowBounds, kContentBounds, screen_info, "25.0.0.123", | 172 kObfuscatedGaiaId, kWindowBounds, kContentBounds, screen_info, |
| 173 kCharset, kAcceptLanguages, base::Time::Now(), DIALOG_TYPE_AUTOCHECKOUT, | 173 "25.0.0.123", kCharset, kAcceptLanguages, base::Time::Now(), |
| 174 g_browser_process->GetApplicationLocale(), | 174 DIALOG_TYPE_AUTOCHECKOUT, g_browser_process->GetApplicationLocale(), |
| 175 base::Bind(&AutofillRiskFingerprintTest::GetFingerprintTestCallback, | 175 base::Bind(&AutofillRiskFingerprintTest::GetFingerprintTestCallback, |
| 176 base::Unretained(this))); | 176 base::Unretained(this))); |
| 177 | 177 |
| 178 // Wait for the callback to be called. | 178 // Wait for the callback to be called. |
| 179 message_loop_.Run(); | 179 message_loop_.Run(); |
| 180 } | 180 } |
| 181 | 181 |
| 182 } // namespace risk | 182 } // namespace risk |
| 183 } // namespace autofill | 183 } // namespace autofill |
| OLD | NEW |