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

Side by Side Diff: content/renderer/external_popup_menu_unittest.cc

Issue 8230034: Split most of RenderViewTest and associated classes into content. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Mac build breaks. Created 9 years, 2 months 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 | Annotate | Revision Log
« no previous file with comments | « content/content_tests.gypi ('k') | content/renderer/render_view_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/utf_string_conversions.h" 5 #include "base/utf_string_conversions.h"
6 #include "chrome/test/base/render_view_test.h"
7 #include "content/common/view_messages.h" 6 #include "content/common/view_messages.h"
8 #include "content/renderer/render_view_impl.h" 7 #include "content/renderer/render_view_impl.h"
8 #include "content/test/render_view_test.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSize.h" 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSize.h"
11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" 11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
12 12
13 // Tests for the external select popup menu (Mac specific). 13 // Tests for the external select popup menu (Mac specific).
14 14
15 namespace { 15 namespace {
16 16
17 const char* const kSelectID = "mySelect"; 17 const char* const kSelectID = "mySelect";
18 const char* const kEmptySelectID = "myEmptySelect"; 18 const char* const kEmptySelectID = "myEmptySelect";
19 19
20 } // namespace 20 } // namespace
21 21
22 class ExternalPopupMenuTest : public RenderViewTest { 22 class ExternalPopupMenuTest : public content::RenderViewTest {
23 public: 23 public:
24 ExternalPopupMenuTest() {} 24 ExternalPopupMenuTest() {}
25 25
26 RenderViewImpl* view() { 26 RenderViewImpl* view() {
27 return static_cast<RenderViewImpl*>(view_); 27 return static_cast<RenderViewImpl*>(view_);
28 } 28 }
29 29
30 virtual void SetUp() { 30 virtual void SetUp() {
31 RenderViewTest::SetUp(); 31 content::RenderViewTest::SetUp();
32 // We need to set this explictly as RenderMain is not run. 32 // We need to set this explictly as RenderMain is not run.
33 WebKit::WebView::setUseExternalPopupMenus(true); 33 WebKit::WebView::setUseExternalPopupMenus(true);
34 34
35 std::string html = "<select id='mySelect' onchange='selectChanged(this)'>" 35 std::string html = "<select id='mySelect' onchange='selectChanged(this)'>"
36 " <option>zero</option>" 36 " <option>zero</option>"
37 " <option selected='1'>one</option>" 37 " <option selected='1'>one</option>"
38 " <option>two</option>" 38 " <option>two</option>"
39 "</select>" 39 "</select>"
40 "<select id='myEmptySelect'>" 40 "<select id='myEmptySelect'>"
41 "</select>"; 41 "</select>";
(...skipping 22 matching lines...) Expand all
64 } 64 }
65 65
66 protected: 66 protected:
67 virtual bool ShouldRemoveSelectOnChange() const { return false; } 67 virtual bool ShouldRemoveSelectOnChange() const { return false; }
68 68
69 DISALLOW_COPY_AND_ASSIGN(ExternalPopupMenuTest); 69 DISALLOW_COPY_AND_ASSIGN(ExternalPopupMenuTest);
70 }; 70 };
71 71
72 // Normal case: test showing a select popup, canceling/selecting an item. 72 // Normal case: test showing a select popup, canceling/selecting an item.
73 TEST_F(ExternalPopupMenuTest, NormalCase) { 73 TEST_F(ExternalPopupMenuTest, NormalCase) {
74 IPC::TestSink& sink = render_thread_.sink(); 74 IPC::TestSink& sink = render_thread_->sink();
75 75
76 // Click the text field once. 76 // Click the text field once.
77 EXPECT_TRUE(SimulateElementClick(kSelectID)); 77 EXPECT_TRUE(SimulateElementClick(kSelectID));
78 78
79 // We should have sent a message to the browser to show the popup menu. 79 // We should have sent a message to the browser to show the popup menu.
80 const IPC::Message* message = 80 const IPC::Message* message =
81 sink.GetUniqueMessageMatching(ViewHostMsg_ShowPopup::ID); 81 sink.GetUniqueMessageMatching(ViewHostMsg_ShowPopup::ID);
82 ASSERT_TRUE(message != NULL); 82 ASSERT_TRUE(message != NULL);
83 Tuple1<ViewHostMsg_ShowPopup_Params> param; 83 Tuple1<ViewHostMsg_ShowPopup_Params> param;
84 ViewHostMsg_ShowPopup::Read(message, &param); 84 ViewHostMsg_ShowPopup::Read(message, &param);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 // Click the text field once to show the popup. 136 // Click the text field once to show the popup.
137 EXPECT_TRUE(SimulateElementClick(kSelectID)); 137 EXPECT_TRUE(SimulateElementClick(kSelectID));
138 138
139 // Select something, it causes the select to be removed from the page. 139 // Select something, it causes the select to be removed from the page.
140 view()->OnSelectPopupMenuItem(0); 140 view()->OnSelectPopupMenuItem(0);
141 141
142 // Just to check the soundness of the test, call SimulateElementClick again. 142 // Just to check the soundness of the test, call SimulateElementClick again.
143 // It should return false as the select has been removed. 143 // It should return false as the select has been removed.
144 EXPECT_FALSE(SimulateElementClick(kSelectID)); 144 EXPECT_FALSE(SimulateElementClick(kSelectID));
145 } 145 }
OLDNEW
« no previous file with comments | « content/content_tests.gypi ('k') | content/renderer/render_view_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698