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

Side by Side Diff: chrome/renderer/autofill/page_click_tracker_browsertest.cc

Issue 818563003: Tests in browser_tests target should use ChromeRenderViewTest as the base class. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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
« no previous file with comments | « no previous file | extensions/DEPS » ('j') | extensions/DEPS » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "components/autofill/content/renderer/page_click_listener.h" 7 #include "components/autofill/content/renderer/page_click_listener.h"
7 #include "components/autofill/content/renderer/page_click_tracker.h" 8 #include "components/autofill/content/renderer/page_click_tracker.h"
8 #include "content/public/renderer/render_view.h" 9 #include "content/public/renderer/render_view.h"
9 #include "content/public/test/render_view_test.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 #include "third_party/WebKit/public/web/WebDocument.h" 11 #include "third_party/WebKit/public/web/WebDocument.h"
12 #include "third_party/WebKit/public/web/WebInputElement.h" 12 #include "third_party/WebKit/public/web/WebInputElement.h"
13 #include "third_party/WebKit/public/web/WebTextAreaElement.h" 13 #include "third_party/WebKit/public/web/WebTextAreaElement.h"
14 #include "third_party/WebKit/public/web/WebView.h" 14 #include "third_party/WebKit/public/web/WebView.h"
15 #include "third_party/WebKit/public/platform/WebSize.h" 15 #include "third_party/WebKit/public/platform/WebSize.h"
16 #include "ui/events/keycodes/keyboard_codes.h" 16 #include "ui/events/keycodes/keyboard_codes.h"
17 17
18 namespace autofill { 18 namespace autofill {
19 19
(...skipping 14 matching lines...) Expand all
34 form_control_element_clicked_called_ = false; 34 form_control_element_clicked_called_ = false;
35 form_control_element_clicked_.reset(); 35 form_control_element_clicked_.reset();
36 was_focused_ = false; 36 was_focused_ = false;
37 } 37 }
38 38
39 bool form_control_element_clicked_called_; 39 bool form_control_element_clicked_called_;
40 blink::WebFormControlElement form_control_element_clicked_; 40 blink::WebFormControlElement form_control_element_clicked_;
41 bool was_focused_; 41 bool was_focused_;
42 }; 42 };
43 43
44 class PageClickTrackerTest : public content::RenderViewTest { 44 class PageClickTrackerTest : public ChromeRenderViewTest {
45 protected: 45 protected:
46 void SetUp() override { 46 void SetUp() override {
47 content::RenderViewTest::SetUp(); 47 ChromeRenderViewTest::SetUp();
48 48
49 // RenderView creates PageClickTracker but it doesn't keep it around. 49 // RenderView creates PageClickTracker but it doesn't keep it around.
50 // Rather than make it do so for the test, we create a new object. 50 // Rather than make it do so for the test, we create a new object.
51 page_click_tracker_.reset(new PageClickTracker(view_, &test_listener_)); 51 page_click_tracker_.reset(new PageClickTracker(view_, &test_listener_));
52 52
53 LoadHTML("<form>" 53 LoadHTML("<form>"
54 " <input type='text' id='text_1'></input><br>" 54 " <input type='text' id='text_1'></input><br>"
55 " <input type='text' id='text_2'></input><br>" 55 " <input type='text' id='text_2'></input><br>"
56 " <textarea id='textarea_1'></textarea><br>" 56 " <textarea id='textarea_1'></textarea><br>"
57 " <textarea id='textarea_2'></textarea><br>" 57 " <textarea id='textarea_2'></textarea><br>"
58 " <input type='button' id='button'></input><br>" 58 " <input type='button' id='button'></input><br>"
59 "</form>"); 59 "</form>");
60 GetWebWidget()->resize(blink::WebSize(500, 500)); 60 GetWebWidget()->resize(blink::WebSize(500, 500));
61 GetWebWidget()->setFocus(true); 61 GetWebWidget()->setFocus(true);
62 blink::WebDocument document = view_->GetWebView()->mainFrame()->document(); 62 blink::WebDocument document = view_->GetWebView()->mainFrame()->document();
63 text_ = document.getElementById("text_1"); 63 text_ = document.getElementById("text_1");
64 textarea_ = document.getElementById("textarea_1"); 64 textarea_ = document.getElementById("textarea_1");
65 ASSERT_FALSE(text_.isNull()); 65 ASSERT_FALSE(text_.isNull());
66 ASSERT_FALSE(textarea_.isNull()); 66 ASSERT_FALSE(textarea_.isNull());
67 } 67 }
68 68
69 void TearDown() override { 69 void TearDown() override {
70 text_.reset(); 70 text_.reset();
71 textarea_.reset(); 71 textarea_.reset();
72 test_listener_.ClearResults(); 72 test_listener_.ClearResults();
73 page_click_tracker_.reset(); 73 page_click_tracker_.reset();
74 content::RenderViewTest::TearDown(); 74 ChromeRenderViewTest::TearDown();
75 } 75 }
76 76
77 // Simulates a click on the given element and then waits for the stack 77 // Simulates a click on the given element and then waits for the stack
78 // to unwind. 78 // to unwind.
79 void SendElementClick(const std::string& element_id) { 79 void SendElementClick(const std::string& element_id) {
80 EXPECT_TRUE(SimulateElementClick(element_id)); 80 EXPECT_TRUE(SimulateElementClick(element_id));
81 ProcessPendingMessages(); 81 ProcessPendingMessages();
82 } 82 }
83 83
84 // Send all the messages required for a complete key press. 84 // Send all the messages required for a complete key press.
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 EXPECT_TRUE(test_listener_.was_focused_); 142 EXPECT_TRUE(test_listener_.was_focused_);
143 EXPECT_TRUE(textarea_ == test_listener_.form_control_element_clicked_); 143 EXPECT_TRUE(textarea_ == test_listener_.form_control_element_clicked_);
144 test_listener_.ClearResults(); 144 test_listener_.ClearResults();
145 145
146 // Click the button, no notification should happen (this is not a text-input). 146 // Click the button, no notification should happen (this is not a text-input).
147 SendElementClick("button"); 147 SendElementClick("button");
148 EXPECT_FALSE(test_listener_.form_control_element_clicked_called_); 148 EXPECT_FALSE(test_listener_.form_control_element_clicked_called_);
149 } 149 }
150 150
151 } // namespace autofill 151 } // namespace autofill
OLDNEW
« no previous file with comments | « no previous file | extensions/DEPS » ('j') | extensions/DEPS » ('J')

Powered by Google App Engine
This is Rietveld 408576698