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/test/base/in_process_browser_test.h" | 10 #include "chrome/test/base/in_process_browser_test.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 public: | 26 public: |
27 AutofillRiskFingerprintTest() | 27 AutofillRiskFingerprintTest() |
28 : kWindowBounds(2, 3, 5, 7), | 28 : kWindowBounds(2, 3, 5, 7), |
29 kContentBounds(11, 13, 17, 37), | 29 kContentBounds(11, 13, 17, 37), |
30 kScreenBounds(0, 0, 101, 71), | 30 kScreenBounds(0, 0, 101, 71), |
31 kAvailableScreenBounds(0, 11, 101, 60), | 31 kAvailableScreenBounds(0, 11, 101, 60), |
32 kUnavailableScreenBounds(0, 0, 101, 11), | 32 kUnavailableScreenBounds(0, 0, 101, 11), |
33 message_loop_(MessageLoop::TYPE_UI) {} | 33 message_loop_(MessageLoop::TYPE_UI) {} |
34 | 34 |
35 void GetFingerprintTestCallback(scoped_ptr<Fingerprint> fingerprint) { | 35 void GetFingerprintTestCallback(scoped_ptr<Fingerprint> fingerprint) { |
36 // TODO(isherman): Investigating http://crbug.com/174296 | |
37 LOG(WARNING) << "Callback called."; | |
38 | |
39 // Verify that all fields Chrome can fill have been filled. | 36 // Verify that all fields Chrome can fill have been filled. |
40 ASSERT_TRUE(fingerprint->has_machine_characteristics()); | 37 ASSERT_TRUE(fingerprint->has_machine_characteristics()); |
41 const Fingerprint_MachineCharacteristics& machine = | 38 const Fingerprint_MachineCharacteristics& machine = |
42 fingerprint->machine_characteristics(); | 39 fingerprint->machine_characteristics(); |
43 ASSERT_TRUE(machine.has_operating_system_build()); | 40 ASSERT_TRUE(machine.has_operating_system_build()); |
44 ASSERT_TRUE(machine.has_browser_install_time_hours()); | 41 ASSERT_TRUE(machine.has_browser_install_time_hours()); |
45 ASSERT_GT(machine.font_size(), 0); | 42 ASSERT_GT(machine.font_size(), 0); |
46 ASSERT_GT(machine.plugin_size(), 0); | 43 ASSERT_GT(machine.plugin_size(), 0); |
47 ASSERT_TRUE(machine.has_utc_offset_ms()); | 44 ASSERT_TRUE(machine.has_utc_offset_ms()); |
48 ASSERT_TRUE(machine.has_browser_language()); | 45 ASSERT_TRUE(machine.has_browser_language()); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 EXPECT_EQ(kContentBounds.width(), | 91 EXPECT_EQ(kContentBounds.width(), |
95 transient_state.inner_window_size().width()); | 92 transient_state.inner_window_size().width()); |
96 EXPECT_EQ(kContentBounds.height(), | 93 EXPECT_EQ(kContentBounds.height(), |
97 transient_state.inner_window_size().height()); | 94 transient_state.inner_window_size().height()); |
98 EXPECT_EQ(kWindowBounds.width(), | 95 EXPECT_EQ(kWindowBounds.width(), |
99 transient_state.outer_window_size().width()); | 96 transient_state.outer_window_size().width()); |
100 EXPECT_EQ(kWindowBounds.height(), | 97 EXPECT_EQ(kWindowBounds.height(), |
101 transient_state.outer_window_size().height()); | 98 transient_state.outer_window_size().height()); |
102 EXPECT_EQ(kGaiaId, fingerprint->metadata().gaia_id()); | 99 EXPECT_EQ(kGaiaId, fingerprint->metadata().gaia_id()); |
103 | 100 |
104 // TODO(isherman): Investigating http://crbug.com/174296 | |
105 LOG(WARNING) << "Stopping the message loop."; | |
106 message_loop_.Quit(); | 101 message_loop_.Quit(); |
107 } | 102 } |
108 | 103 |
109 protected: | 104 protected: |
110 const gfx::Rect kWindowBounds; | 105 const gfx::Rect kWindowBounds; |
111 const gfx::Rect kContentBounds; | 106 const gfx::Rect kContentBounds; |
112 const gfx::Rect kScreenBounds; | 107 const gfx::Rect kScreenBounds; |
113 const gfx::Rect kAvailableScreenBounds; | 108 const gfx::Rect kAvailableScreenBounds; |
114 const gfx::Rect kUnavailableScreenBounds; | 109 const gfx::Rect kUnavailableScreenBounds; |
115 MessageLoop message_loop_; | 110 MessageLoop message_loop_; |
116 }; | 111 }; |
117 | 112 |
118 // This test is flaky on Windows. See http://crbug.com/178356. | 113 // This test is flaky on Windows. See http://crbug.com/178356. |
119 #if defined(OS_WIN) | 114 #if defined(OS_WIN) |
120 #define MAYBE_GetFingerprint DISABLED_GetFingerprint | 115 #define MAYBE_GetFingerprint DISABLED_GetFingerprint |
121 #else | 116 #else |
122 #define MAYBE_GetFingerprint GetFingerprint | 117 #define MAYBE_GetFingerprint GetFingerprint |
123 #endif | 118 #endif |
124 // Test that getting a fingerprint works on some basic level. | 119 // Test that getting a fingerprint works on some basic level. |
125 IN_PROC_BROWSER_TEST_F(AutofillRiskFingerprintTest, MAYBE_GetFingerprint) { | 120 IN_PROC_BROWSER_TEST_F(AutofillRiskFingerprintTest, MAYBE_GetFingerprint) { |
126 WebKit::WebScreenInfo screen_info; | 121 WebKit::WebScreenInfo screen_info; |
127 screen_info.depth = kScreenColorDepth; | 122 screen_info.depth = kScreenColorDepth; |
128 screen_info.rect = WebKit::WebRect(kScreenBounds); | 123 screen_info.rect = WebKit::WebRect(kScreenBounds); |
129 screen_info.availableRect = WebKit::WebRect(kAvailableScreenBounds); | 124 screen_info.availableRect = WebKit::WebRect(kAvailableScreenBounds); |
130 | 125 |
131 // TODO(isherman): Investigating http://crbug.com/174296 | |
132 LOG(WARNING) << "Loading fingerprint."; | |
133 internal::GetFingerprintInternal( | 126 internal::GetFingerprintInternal( |
134 kGaiaId, kWindowBounds, kContentBounds, screen_info, | 127 kGaiaId, kWindowBounds, kContentBounds, screen_info, |
135 "25.0.0.123", kCharset, kAcceptLanguages, base::Time::Now(), | 128 "25.0.0.123", kCharset, kAcceptLanguages, base::Time::Now(), |
136 base::Bind(&AutofillRiskFingerprintTest::GetFingerprintTestCallback, | 129 base::Bind(&AutofillRiskFingerprintTest::GetFingerprintTestCallback, |
137 base::Unretained(this))); | 130 base::Unretained(this))); |
138 | 131 |
139 // Wait for the callback to be called. | 132 // Wait for the callback to be called. |
140 // TODO(isherman): Investigating http://crbug.com/174296 | |
141 LOG(WARNING) << "Waiting for the callback to be called."; | |
142 message_loop_.Run(); | 133 message_loop_.Run(); |
143 } | 134 } |
144 | 135 |
145 } // namespace risk | 136 } // namespace risk |
146 } // namespace autofill | 137 } // namespace autofill |
OLD | NEW |