| 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 EXPECT_TRUE(test_listener_.form_control_element_clicked_called_); | 107 EXPECT_TRUE(test_listener_.form_control_element_clicked_called_); |
| 108 EXPECT_TRUE(test_listener_.was_focused_); | 108 EXPECT_TRUE(test_listener_.was_focused_); |
| 109 EXPECT_TRUE(text_ == test_listener_.form_control_element_clicked_); | 109 EXPECT_TRUE(text_ == test_listener_.form_control_element_clicked_); |
| 110 test_listener_.ClearResults(); | 110 test_listener_.ClearResults(); |
| 111 | 111 |
| 112 // Click the button, no notification should happen (this is not a text-input). | 112 // Click the button, no notification should happen (this is not a text-input). |
| 113 EXPECT_TRUE(SimulateElementClick("button")); | 113 EXPECT_TRUE(SimulateElementClick("button")); |
| 114 EXPECT_FALSE(test_listener_.form_control_element_clicked_called_); | 114 EXPECT_FALSE(test_listener_.form_control_element_clicked_called_); |
| 115 } | 115 } |
| 116 | 116 |
| 117 // Tests that PageClickTracker does not notify when there is right click. |
| 118 TEST_F(PageClickTrackerTest, PageClickTrackerInputRightClicked) { |
| 119 EXPECT_NE(text_, text_.document().focusedElement()); |
| 120 // Right click the text field once. |
| 121 EXPECT_TRUE(SimulateElementRightClick("text_1")); |
| 122 EXPECT_FALSE(test_listener_.form_control_element_clicked_called_); |
| 123 EXPECT_FALSE(test_listener_.was_focused_); |
| 124 EXPECT_NE(text_, test_listener_.form_control_element_clicked_); |
| 125 } |
| 126 |
| 117 TEST_F(PageClickTrackerTest, PageClickTrackerInputFocusedAndClicked) { | 127 TEST_F(PageClickTrackerTest, PageClickTrackerInputFocusedAndClicked) { |
| 118 // Focus the text field without a click. | 128 // Focus the text field without a click. |
| 119 ExecuteJavaScript("document.getElementById('text_1').focus();"); | 129 ExecuteJavaScript("document.getElementById('text_1').focus();"); |
| 120 EXPECT_FALSE(test_listener_.form_control_element_clicked_called_); | 130 EXPECT_FALSE(test_listener_.form_control_element_clicked_called_); |
| 121 test_listener_.ClearResults(); | 131 test_listener_.ClearResults(); |
| 122 | 132 |
| 123 // 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. |
| 124 EXPECT_TRUE(SimulateElementClick("text_1")); | 134 EXPECT_TRUE(SimulateElementClick("text_1")); |
| 125 EXPECT_TRUE(test_listener_.form_control_element_clicked_called_); | 135 EXPECT_TRUE(test_listener_.form_control_element_clicked_called_); |
| 126 EXPECT_TRUE(test_listener_.was_focused_); | 136 EXPECT_TRUE(test_listener_.was_focused_); |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 // 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. |
| 230 gfx::Rect element_bounds = GetElementBounds("text_1"); | 240 gfx::Rect element_bounds = GetElementBounds("text_1"); |
| 231 SimulateRectTap(element_bounds - | 241 SimulateRectTap(element_bounds - |
| 232 gfx::Vector2d(element_bounds.width() / 2 + 1, 0)); | 242 gfx::Vector2d(element_bounds.width() / 2 + 1, 0)); |
| 233 EXPECT_TRUE(test_listener_.form_control_element_clicked_called_); | 243 EXPECT_TRUE(test_listener_.form_control_element_clicked_called_); |
| 234 EXPECT_FALSE(test_listener_.was_focused_); | 244 EXPECT_FALSE(test_listener_.was_focused_); |
| 235 EXPECT_TRUE(text_ == test_listener_.form_control_element_clicked_); | 245 EXPECT_TRUE(text_ == test_listener_.form_control_element_clicked_); |
| 236 } | 246 } |
| 237 | 247 |
| 238 } // namespace autofill | 248 } // namespace autofill |
| OLD | NEW |