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

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

Issue 1159553007: Move Tuple to base namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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
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/strings/utf_string_conversions.h" 5 #include "base/strings/utf_string_conversions.h"
6 #include "content/common/frame_messages.h" 6 #include "content/common/frame_messages.h"
7 #include "content/public/test/render_view_test.h" 7 #include "content/public/test/render_view_test.h"
8 #include "content/renderer/render_frame_impl.h" 8 #include "content/renderer/render_frame_impl.h"
9 #include "content/renderer/render_view_impl.h" 9 #include "content/renderer/render_view_impl.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 TEST_F(ExternalPopupMenuTest, NormalCase) { 79 TEST_F(ExternalPopupMenuTest, NormalCase) {
80 IPC::TestSink& sink = render_thread_->sink(); 80 IPC::TestSink& sink = render_thread_->sink();
81 81
82 // Click the text field once. 82 // Click the text field once.
83 EXPECT_TRUE(SimulateElementClick(kSelectID)); 83 EXPECT_TRUE(SimulateElementClick(kSelectID));
84 84
85 // We should have sent a message to the browser to show the popup menu. 85 // We should have sent a message to the browser to show the popup menu.
86 const IPC::Message* message = 86 const IPC::Message* message =
87 sink.GetUniqueMessageMatching(FrameHostMsg_ShowPopup::ID); 87 sink.GetUniqueMessageMatching(FrameHostMsg_ShowPopup::ID);
88 ASSERT_TRUE(message != NULL); 88 ASSERT_TRUE(message != NULL);
89 Tuple<FrameHostMsg_ShowPopup_Params> param; 89 base::Tuple<FrameHostMsg_ShowPopup_Params> param;
90 FrameHostMsg_ShowPopup::Read(message, &param); 90 FrameHostMsg_ShowPopup::Read(message, &param);
91 ASSERT_EQ(3U, get<0>(param).popup_items.size()); 91 ASSERT_EQ(3U, base::get<0>(param).popup_items.size());
92 EXPECT_EQ(1, get<0>(param).selected_item); 92 EXPECT_EQ(1, base::get<0>(param).selected_item);
93 93
94 // Simulate the user canceling the popup; the index should not have changed. 94 // Simulate the user canceling the popup; the index should not have changed.
95 frame()->OnSelectPopupMenuItem(-1); 95 frame()->OnSelectPopupMenuItem(-1);
96 EXPECT_EQ(1, GetSelectedIndex()); 96 EXPECT_EQ(1, GetSelectedIndex());
97 97
98 // Show the pop-up again and this time make a selection. 98 // Show the pop-up again and this time make a selection.
99 EXPECT_TRUE(SimulateElementClick(kSelectID)); 99 EXPECT_TRUE(SimulateElementClick(kSelectID));
100 frame()->OnSelectPopupMenuItem(0); 100 frame()->OnSelectPopupMenuItem(0);
101 EXPECT_EQ(0, GetSelectedIndex()); 101 EXPECT_EQ(0, GetSelectedIndex());
102 102
103 // Show the pop-up again and make another selection. 103 // Show the pop-up again and make another selection.
104 sink.ClearMessages(); 104 sink.ClearMessages();
105 EXPECT_TRUE(SimulateElementClick(kSelectID)); 105 EXPECT_TRUE(SimulateElementClick(kSelectID));
106 message = sink.GetUniqueMessageMatching(FrameHostMsg_ShowPopup::ID); 106 message = sink.GetUniqueMessageMatching(FrameHostMsg_ShowPopup::ID);
107 ASSERT_TRUE(message != NULL); 107 ASSERT_TRUE(message != NULL);
108 FrameHostMsg_ShowPopup::Read(message, &param); 108 FrameHostMsg_ShowPopup::Read(message, &param);
109 ASSERT_EQ(3U, get<0>(param).popup_items.size()); 109 ASSERT_EQ(3U, base::get<0>(param).popup_items.size());
110 EXPECT_EQ(0, get<0>(param).selected_item); 110 EXPECT_EQ(0, base::get<0>(param).selected_item);
111 } 111 }
112 112
113 // Page shows popup, then navigates away while popup showing, then select. 113 // Page shows popup, then navigates away while popup showing, then select.
114 TEST_F(ExternalPopupMenuTest, ShowPopupThenNavigate) { 114 TEST_F(ExternalPopupMenuTest, ShowPopupThenNavigate) {
115 // Click the text field once. 115 // Click the text field once.
116 EXPECT_TRUE(SimulateElementClick(kSelectID)); 116 EXPECT_TRUE(SimulateElementClick(kSelectID));
117 117
118 // Now we navigate to another pager. 118 // Now we navigate to another pager.
119 LoadHTML("<blink>Awesome page!</blink>"); 119 LoadHTML("<blink>Awesome page!</blink>");
120 120
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 TEST_F(ExternalPopupMenuDisplayNoneTest, SelectItem) { 182 TEST_F(ExternalPopupMenuDisplayNoneTest, SelectItem) {
183 IPC::TestSink& sink = render_thread_->sink(); 183 IPC::TestSink& sink = render_thread_->sink();
184 184
185 // Click the text field once to show the popup. 185 // Click the text field once to show the popup.
186 EXPECT_TRUE(SimulateElementClick(kSelectID)); 186 EXPECT_TRUE(SimulateElementClick(kSelectID));
187 187
188 // Read the message sent to browser to show the popup menu. 188 // Read the message sent to browser to show the popup menu.
189 const IPC::Message* message = 189 const IPC::Message* message =
190 sink.GetUniqueMessageMatching(FrameHostMsg_ShowPopup::ID); 190 sink.GetUniqueMessageMatching(FrameHostMsg_ShowPopup::ID);
191 ASSERT_TRUE(message != NULL); 191 ASSERT_TRUE(message != NULL);
192 Tuple<FrameHostMsg_ShowPopup_Params> param; 192 base::Tuple<FrameHostMsg_ShowPopup_Params> param;
193 FrameHostMsg_ShowPopup::Read(message, &param); 193 FrameHostMsg_ShowPopup::Read(message, &param);
194 // Number of items should match item count minus the number 194 // Number of items should match item count minus the number
195 // of "display: none" items. 195 // of "display: none" items.
196 ASSERT_EQ(5U, get<0>(param).popup_items.size()); 196 ASSERT_EQ(5U, base::get<0>(param).popup_items.size());
197 197
198 // Select index 1 item. This should select item with index 2, 198 // Select index 1 item. This should select item with index 2,
199 // skipping the item with 'display: none' 199 // skipping the item with 'display: none'
200 frame()->OnSelectPopupMenuItem(1); 200 frame()->OnSelectPopupMenuItem(1);
201 201
202 EXPECT_EQ(2, GetSelectedIndex()); 202 EXPECT_EQ(2, GetSelectedIndex());
203 } 203 }
204 204
205 } // namespace content 205 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/browser_plugin/browser_plugin_manager.cc ('k') | content/renderer/input/input_event_filter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698