Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(461)

Side by Side Diff: chrome/browser/autofill/risk/fingerprint_browsertest.cc

Issue 14904002: Load and send Wallet Risk params after user has agreed (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 #include "third_party/WebKit/Source/Platform/chromium/public/WebRect.h" 14 #include "third_party/WebKit/Source/Platform/chromium/public/WebRect.h"
15 #include "third_party/WebKit/Source/Platform/chromium/public/WebScreenInfo.h" 15 #include "third_party/WebKit/Source/Platform/chromium/public/WebScreenInfo.h"
16 #include "ui/gfx/rect.h" 16 #include "ui/gfx/rect.h"
17 17
18 namespace autofill { 18 namespace autofill {
19 namespace risk { 19 namespace risk {
20 20
21 const int64 kGaiaId = GG_INT64_C(99194853094755497); 21 const uint64 kObfuscatedGaiaId = GG_UINT64_C(16571487432910023183);
22 const char kCharset[] = "UTF-8"; 22 const char kCharset[] = "UTF-8";
23 const char kAcceptLanguages[] = "en-US,en"; 23 const char kAcceptLanguages[] = "en-US,en";
24 const int kScreenColorDepth = 53; 24 const int kScreenColorDepth = 53;
25 25
26 class AutofillRiskFingerprintTest : public InProcessBrowserTest { 26 class AutofillRiskFingerprintTest : public InProcessBrowserTest {
27 public: 27 public:
28 AutofillRiskFingerprintTest() 28 AutofillRiskFingerprintTest()
29 : kWindowBounds(2, 3, 5, 7), 29 : kWindowBounds(2, 3, 5, 7),
30 kContentBounds(11, 13, 17, 37), 30 kContentBounds(11, 13, 17, 37),
31 kScreenBounds(0, 0, 101, 71), 31 kScreenBounds(0, 0, 101, 71),
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 fingerprint->transient_state(); 70 fingerprint->transient_state();
71 ASSERT_TRUE(transient_state.has_inner_window_size()); 71 ASSERT_TRUE(transient_state.has_inner_window_size());
72 ASSERT_TRUE(transient_state.has_outer_window_size()); 72 ASSERT_TRUE(transient_state.has_outer_window_size());
73 ASSERT_TRUE(transient_state.inner_window_size().has_width()); 73 ASSERT_TRUE(transient_state.inner_window_size().has_width());
74 ASSERT_TRUE(transient_state.inner_window_size().has_height()); 74 ASSERT_TRUE(transient_state.inner_window_size().has_height());
75 ASSERT_TRUE(transient_state.outer_window_size().has_width()); 75 ASSERT_TRUE(transient_state.outer_window_size().has_width());
76 ASSERT_TRUE(transient_state.outer_window_size().has_height()); 76 ASSERT_TRUE(transient_state.outer_window_size().has_height());
77 77
78 ASSERT_TRUE(fingerprint->has_metadata()); 78 ASSERT_TRUE(fingerprint->has_metadata());
79 ASSERT_TRUE(fingerprint->metadata().has_timestamp_ms()); 79 ASSERT_TRUE(fingerprint->metadata().has_timestamp_ms());
80 ASSERT_TRUE(fingerprint->metadata().has_gaia_id()); 80 ASSERT_TRUE(fingerprint->metadata().has_obfuscated_gaia_id());
81 ASSERT_TRUE(fingerprint->metadata().has_fingerprinter_version()); 81 ASSERT_TRUE(fingerprint->metadata().has_fingerprinter_version());
82 82
83 // Some values have exact known (mocked out) values: 83 // Some values have exact known (mocked out) values:
84 ASSERT_EQ(2, machine.requested_language_size()); 84 ASSERT_EQ(2, machine.requested_language_size());
85 EXPECT_EQ("en-US", machine.requested_language(0)); 85 EXPECT_EQ("en-US", machine.requested_language(0));
86 EXPECT_EQ("en", machine.requested_language(1)); 86 EXPECT_EQ("en", machine.requested_language(1));
87 EXPECT_EQ(kCharset, machine.charset()); 87 EXPECT_EQ(kCharset, machine.charset());
88 EXPECT_EQ(kScreenColorDepth, machine.screen_color_depth()); 88 EXPECT_EQ(kScreenColorDepth, machine.screen_color_depth());
89 EXPECT_EQ(kUnavailableScreenBounds.width(), 89 EXPECT_EQ(kUnavailableScreenBounds.width(),
90 machine.unavailable_screen_size().width()); 90 machine.unavailable_screen_size().width());
91 EXPECT_EQ(kUnavailableScreenBounds.height(), 91 EXPECT_EQ(kUnavailableScreenBounds.height(),
92 machine.unavailable_screen_size().height()); 92 machine.unavailable_screen_size().height());
93 EXPECT_EQ( 93 EXPECT_EQ(
94 Fingerprint_MachineCharacteristics_BrowserFeature_FEATURE_AUTOCHECKOUT, 94 Fingerprint_MachineCharacteristics_BrowserFeature_FEATURE_AUTOCHECKOUT,
95 machine.browser_feature()); 95 machine.browser_feature());
96 EXPECT_EQ(kContentBounds.width(), 96 EXPECT_EQ(kContentBounds.width(),
97 transient_state.inner_window_size().width()); 97 transient_state.inner_window_size().width());
98 EXPECT_EQ(kContentBounds.height(), 98 EXPECT_EQ(kContentBounds.height(),
99 transient_state.inner_window_size().height()); 99 transient_state.inner_window_size().height());
100 EXPECT_EQ(kWindowBounds.width(), 100 EXPECT_EQ(kWindowBounds.width(),
101 transient_state.outer_window_size().width()); 101 transient_state.outer_window_size().width());
102 EXPECT_EQ(kWindowBounds.height(), 102 EXPECT_EQ(kWindowBounds.height(),
103 transient_state.outer_window_size().height()); 103 transient_state.outer_window_size().height());
104 EXPECT_EQ(kGaiaId, fingerprint->metadata().gaia_id()); 104 EXPECT_EQ(kObfuscatedGaiaId, fingerprint->metadata().obfuscated_gaia_id());
105 105
106 message_loop_.Quit(); 106 message_loop_.Quit();
107 } 107 }
108 108
109 protected: 109 protected:
110 const gfx::Rect kWindowBounds; 110 const gfx::Rect kWindowBounds;
111 const gfx::Rect kContentBounds; 111 const gfx::Rect kContentBounds;
112 const gfx::Rect kScreenBounds; 112 const gfx::Rect kScreenBounds;
113 const gfx::Rect kAvailableScreenBounds; 113 const gfx::Rect kAvailableScreenBounds;
114 const gfx::Rect kUnavailableScreenBounds; 114 const gfx::Rect kUnavailableScreenBounds;
115 MessageLoop message_loop_; 115 MessageLoop message_loop_;
116 }; 116 };
117 117
118 // This test is flaky on Windows. See http://crbug.com/178356. 118 // This test is flaky on Windows. See http://crbug.com/178356.
119 #if defined(OS_WIN) 119 #if defined(OS_WIN)
120 #define MAYBE_GetFingerprint DISABLED_GetFingerprint 120 #define MAYBE_GetFingerprint DISABLED_GetFingerprint
121 #else 121 #else
122 #define MAYBE_GetFingerprint GetFingerprint 122 #define MAYBE_GetFingerprint GetFingerprint
123 #endif 123 #endif
124 // Test that getting a fingerprint works on some basic level. 124 // Test that getting a fingerprint works on some basic level.
125 IN_PROC_BROWSER_TEST_F(AutofillRiskFingerprintTest, MAYBE_GetFingerprint) { 125 IN_PROC_BROWSER_TEST_F(AutofillRiskFingerprintTest, MAYBE_GetFingerprint) {
126 WebKit::WebScreenInfo screen_info; 126 WebKit::WebScreenInfo screen_info;
127 screen_info.depth = kScreenColorDepth; 127 screen_info.depth = kScreenColorDepth;
128 screen_info.rect = WebKit::WebRect(kScreenBounds); 128 screen_info.rect = WebKit::WebRect(kScreenBounds);
129 screen_info.availableRect = WebKit::WebRect(kAvailableScreenBounds); 129 screen_info.availableRect = WebKit::WebRect(kAvailableScreenBounds);
130 130
131 internal::GetFingerprintInternal( 131 internal::GetFingerprintInternal(
132 kGaiaId, kWindowBounds, kContentBounds, screen_info, "25.0.0.123", 132 kObfuscatedGaiaId, kWindowBounds, kContentBounds, screen_info,
133 kCharset, kAcceptLanguages, base::Time::Now(), DIALOG_TYPE_AUTOCHECKOUT, 133 "25.0.0.123", kCharset, kAcceptLanguages, base::Time::Now(),
134 g_browser_process->GetApplicationLocale(), 134 DIALOG_TYPE_AUTOCHECKOUT, g_browser_process->GetApplicationLocale(),
135 base::Bind(&AutofillRiskFingerprintTest::GetFingerprintTestCallback, 135 base::Bind(&AutofillRiskFingerprintTest::GetFingerprintTestCallback,
136 base::Unretained(this))); 136 base::Unretained(this)));
137 137
138 // Wait for the callback to be called. 138 // Wait for the callback to be called.
139 message_loop_.Run(); 139 message_loop_.Run();
140 } 140 }
141 141
142 } // namespace risk 142 } // namespace risk
143 } // namespace autofill 143 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698