OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "chrome/test/base/chrome_render_view_test.h" | 6 #include "chrome/test/base/chrome_render_view_test.h" |
7 #include "components/autofill/content/renderer/page_click_listener.h" | 7 #include "components/autofill/content/renderer/page_click_listener.h" |
8 #include "components/autofill/content/renderer/page_click_tracker.h" | 8 #include "components/autofill/content/renderer/page_click_tracker.h" |
9 #include "content/public/renderer/render_view.h" | 9 #include "content/public/renderer/render_view.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 EXPECT_NE(text_, text_.document().focusedElement()); | 119 EXPECT_NE(text_, text_.document().focusedElement()); |
120 // Right click the text field once. | 120 // Right click the text field once. |
121 EXPECT_TRUE(SimulateElementRightClick("text_1")); | 121 EXPECT_TRUE(SimulateElementRightClick("text_1")); |
122 EXPECT_FALSE(test_listener_.form_control_element_clicked_called_); | 122 EXPECT_FALSE(test_listener_.form_control_element_clicked_called_); |
123 EXPECT_FALSE(test_listener_.was_focused_); | 123 EXPECT_FALSE(test_listener_.was_focused_); |
124 EXPECT_NE(text_, test_listener_.form_control_element_clicked_); | 124 EXPECT_NE(text_, test_listener_.form_control_element_clicked_); |
125 } | 125 } |
126 | 126 |
127 TEST_F(PageClickTrackerTest, PageClickTrackerInputFocusedAndClicked) { | 127 TEST_F(PageClickTrackerTest, PageClickTrackerInputFocusedAndClicked) { |
128 // Focus the text field without a click. | 128 // Focus the text field without a click. |
129 ExecuteJavaScript("document.getElementById('text_1').focus();"); | 129 ExecuteJavaScriptForTests("document.getElementById('text_1').focus();"); |
130 EXPECT_FALSE(test_listener_.form_control_element_clicked_called_); | 130 EXPECT_FALSE(test_listener_.form_control_element_clicked_called_); |
131 test_listener_.ClearResults(); | 131 test_listener_.ClearResults(); |
132 | 132 |
133 // Click the focused text field to test that was_focused_ is set correctly. | 133 // Click the focused text field to test that was_focused_ is set correctly. |
134 EXPECT_TRUE(SimulateElementClick("text_1")); | 134 EXPECT_TRUE(SimulateElementClick("text_1")); |
135 EXPECT_TRUE(test_listener_.form_control_element_clicked_called_); | 135 EXPECT_TRUE(test_listener_.form_control_element_clicked_called_); |
136 EXPECT_TRUE(test_listener_.was_focused_); | 136 EXPECT_TRUE(test_listener_.was_focused_); |
137 EXPECT_TRUE(text_ == test_listener_.form_control_element_clicked_); | 137 EXPECT_TRUE(text_ == test_listener_.form_control_element_clicked_); |
138 } | 138 } |
139 | 139 |
(...skipping 14 matching lines...) Expand all Loading... |
154 EXPECT_TRUE(textarea_ == test_listener_.form_control_element_clicked_); | 154 EXPECT_TRUE(textarea_ == test_listener_.form_control_element_clicked_); |
155 test_listener_.ClearResults(); | 155 test_listener_.ClearResults(); |
156 | 156 |
157 // Click the button, no notification should happen (this is not a text-input). | 157 // Click the button, no notification should happen (this is not a text-input). |
158 EXPECT_TRUE(SimulateElementClick("button")); | 158 EXPECT_TRUE(SimulateElementClick("button")); |
159 EXPECT_FALSE(test_listener_.form_control_element_clicked_called_); | 159 EXPECT_FALSE(test_listener_.form_control_element_clicked_called_); |
160 } | 160 } |
161 | 161 |
162 TEST_F(PageClickTrackerTest, PageClickTrackerTextAreaFocusedAndClicked) { | 162 TEST_F(PageClickTrackerTest, PageClickTrackerTextAreaFocusedAndClicked) { |
163 // Focus the textarea without a click. | 163 // Focus the textarea without a click. |
164 ExecuteJavaScript("document.getElementById('textarea_1').focus();"); | 164 ExecuteJavaScriptForTests("document.getElementById('textarea_1').focus();"); |
165 EXPECT_FALSE(test_listener_.form_control_element_clicked_called_); | 165 EXPECT_FALSE(test_listener_.form_control_element_clicked_called_); |
166 test_listener_.ClearResults(); | 166 test_listener_.ClearResults(); |
167 | 167 |
168 // Click the focused text field to test that was_focused_ is set correctly. | 168 // Click the focused text field to test that was_focused_ is set correctly. |
169 EXPECT_TRUE(SimulateElementClick("textarea_1")); | 169 EXPECT_TRUE(SimulateElementClick("textarea_1")); |
170 EXPECT_TRUE(test_listener_.form_control_element_clicked_called_); | 170 EXPECT_TRUE(test_listener_.form_control_element_clicked_called_); |
171 EXPECT_TRUE(test_listener_.was_focused_); | 171 EXPECT_TRUE(test_listener_.was_focused_); |
172 EXPECT_TRUE(textarea_ == test_listener_.form_control_element_clicked_); | 172 EXPECT_TRUE(textarea_ == test_listener_.form_control_element_clicked_); |
173 test_listener_.ClearResults(); | 173 test_listener_.ClearResults(); |
174 } | 174 } |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 // Tap outside of element bounds, but tap width is overlapping the field. | 239 // Tap outside of element bounds, but tap width is overlapping the field. |
240 gfx::Rect element_bounds = GetElementBounds("text_1"); | 240 gfx::Rect element_bounds = GetElementBounds("text_1"); |
241 SimulateRectTap(element_bounds - | 241 SimulateRectTap(element_bounds - |
242 gfx::Vector2d(element_bounds.width() / 2 + 1, 0)); | 242 gfx::Vector2d(element_bounds.width() / 2 + 1, 0)); |
243 EXPECT_TRUE(test_listener_.form_control_element_clicked_called_); | 243 EXPECT_TRUE(test_listener_.form_control_element_clicked_called_); |
244 EXPECT_FALSE(test_listener_.was_focused_); | 244 EXPECT_FALSE(test_listener_.was_focused_); |
245 EXPECT_TRUE(text_ == test_listener_.form_control_element_clicked_); | 245 EXPECT_TRUE(text_ == test_listener_.form_control_element_clicked_); |
246 } | 246 } |
247 | 247 |
248 } // namespace autofill | 248 } // namespace autofill |
OLD | NEW |