| 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 <memory> | 5 #include <memory> |
| 6 | 6 |
| 7 #include "chrome/test/base/chrome_render_view_test.h" | 7 #include "chrome/test/base/chrome_render_view_test.h" |
| 8 #include "components/autofill/content/renderer/autofill_agent.h" | 8 #include "components/autofill/content/renderer/autofill_agent.h" |
| 9 #include "components/autofill/content/renderer/page_click_listener.h" | 9 #include "components/autofill/content/renderer/page_click_listener.h" |
| 10 #include "components/autofill/content/renderer/page_click_tracker.h" | 10 #include "components/autofill/content/renderer/page_click_tracker.h" |
| 11 #include "content/public/renderer/render_view.h" | 11 #include "content/public/renderer/render_view.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 13 #include "third_party/WebKit/public/platform/WebFloatPoint.h" | 13 #include "third_party/WebKit/public/platform/WebFloatPoint.h" |
| 14 #include "third_party/WebKit/public/platform/WebSize.h" | 14 #include "third_party/WebKit/public/platform/WebSize.h" |
| 15 #include "third_party/WebKit/public/web/WebDocument.h" | 15 #include "third_party/WebKit/public/web/WebDocument.h" |
| 16 #include "third_party/WebKit/public/web/WebInputElement.h" | 16 #include "third_party/WebKit/public/web/WebInputElement.h" |
| 17 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
| 17 #include "third_party/WebKit/public/web/WebSettings.h" | 18 #include "third_party/WebKit/public/web/WebSettings.h" |
| 18 #include "third_party/WebKit/public/web/WebView.h" | 19 #include "third_party/WebKit/public/web/WebView.h" |
| 19 #include "ui/events/keycodes/keyboard_codes.h" | 20 #include "ui/events/keycodes/keyboard_codes.h" |
| 20 | 21 |
| 21 namespace autofill { | 22 namespace autofill { |
| 22 | 23 |
| 23 class TestPageClickListener : public PageClickListener { | 24 class TestPageClickListener : public PageClickListener { |
| 24 public: | 25 public: |
| 25 TestPageClickListener() | 26 TestPageClickListener() |
| 26 : form_control_element_clicked_called_(false), | 27 : form_control_element_clicked_called_(false), |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 LoadHTML("<form>" | 64 LoadHTML("<form>" |
| 64 " <input type='text' id='text_1'></input><br>" | 65 " <input type='text' id='text_1'></input><br>" |
| 65 " <input type='text' id='text_2'></input><br>" | 66 " <input type='text' id='text_2'></input><br>" |
| 66 " <textarea id='textarea_1'></textarea><br>" | 67 " <textarea id='textarea_1'></textarea><br>" |
| 67 " <textarea id='textarea_2'></textarea><br>" | 68 " <textarea id='textarea_2'></textarea><br>" |
| 68 " <input type='button' id='button'></input><br>" | 69 " <input type='button' id='button'></input><br>" |
| 69 " <input type='button' id='button_2' disabled></input><br>" | 70 " <input type='button' id='button_2' disabled></input><br>" |
| 70 "</form>"); | 71 "</form>"); |
| 71 GetWebWidget()->Resize(blink::WebSize(500, 500)); | 72 GetWebWidget()->Resize(blink::WebSize(500, 500)); |
| 72 GetWebWidget()->SetFocus(true); | 73 GetWebWidget()->SetFocus(true); |
| 73 blink::WebDocument document = | 74 blink::WebDocument document = GetMainFrame()->GetDocument(); |
| 74 view_->GetWebView()->MainFrame()->GetDocument(); | |
| 75 text_ = document.GetElementById("text_1"); | 75 text_ = document.GetElementById("text_1"); |
| 76 textarea_ = document.GetElementById("textarea_1"); | 76 textarea_ = document.GetElementById("textarea_1"); |
| 77 ASSERT_FALSE(text_.IsNull()); | 77 ASSERT_FALSE(text_.IsNull()); |
| 78 ASSERT_FALSE(textarea_.IsNull()); | 78 ASSERT_FALSE(textarea_.IsNull()); |
| 79 | 79 |
| 80 // Enable show-ime event when element is focused by indicating that a user | 80 // Enable show-ime event when element is focused by indicating that a user |
| 81 // gesture has been processed since load. | 81 // gesture has been processed since load. |
| 82 EXPECT_TRUE(SimulateElementClick("button")); | 82 EXPECT_TRUE(SimulateElementClick("button")); |
| 83 } | 83 } |
| 84 | 84 |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 // Tap outside of element bounds, but tap width is overlapping the field. | 242 // Tap outside of element bounds, but tap width is overlapping the field. |
| 243 gfx::Rect element_bounds = GetElementBounds("text_1"); | 243 gfx::Rect element_bounds = GetElementBounds("text_1"); |
| 244 SimulateRectTap(element_bounds - | 244 SimulateRectTap(element_bounds - |
| 245 gfx::Vector2d(element_bounds.width() / 2 + 1, 0)); | 245 gfx::Vector2d(element_bounds.width() / 2 + 1, 0)); |
| 246 EXPECT_TRUE(test_listener_.form_control_element_clicked_called_); | 246 EXPECT_TRUE(test_listener_.form_control_element_clicked_called_); |
| 247 EXPECT_FALSE(test_listener_.was_focused_); | 247 EXPECT_FALSE(test_listener_.was_focused_); |
| 248 EXPECT_TRUE(text_ == test_listener_.form_control_element_clicked_); | 248 EXPECT_TRUE(text_ == test_listener_.form_control_element_clicked_); |
| 249 } | 249 } |
| 250 | 250 |
| 251 } // namespace autofill | 251 } // namespace autofill |
| OLD | NEW |