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

Side by Side Diff: chrome/browser/ui/views/toolbar/toolbar_action_view_unittest.cc

Issue 2477463003: Replace ui::AXViewState with AXNodeData and AXActionData (Closed)
Patch Set: Fix test Created 4 years, 1 month 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/macros.h" 5 #include "base/macros.h"
6 #include "base/run_loop.h" 6 #include "base/run_loop.h"
7 #include "base/strings/string16.h" 7 #include "base/strings/string16.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/browser/sessions/session_tab_helper.h" 9 #include "chrome/browser/sessions/session_tab_helper.h"
10 #include "chrome/browser/ui/toolbar/test_toolbar_action_view_controller.h" 10 #include "chrome/browser/ui/toolbar/test_toolbar_action_view_controller.h"
11 #include "chrome/browser/ui/toolbar/toolbar_action_view_controller.h" 11 #include "chrome/browser/ui/toolbar/toolbar_action_view_controller.h"
12 #include "chrome/browser/ui/views/toolbar/toolbar_action_view.h" 12 #include "chrome/browser/ui/views/toolbar/toolbar_action_view.h"
13 #include "chrome/test/base/testing_profile.h" 13 #include "chrome/test/base/testing_profile.h"
14 #include "content/public/test/test_browser_thread.h" 14 #include "content/public/test/test_browser_thread.h"
15 #include "content/public/test/test_web_contents_factory.h" 15 #include "content/public/test/test_web_contents_factory.h"
16 #include "ui/accessibility/ax_view_state.h" 16 #include "ui/accessibility/ax_node_data.h"
17 #include "ui/events/test/event_generator.h" 17 #include "ui/events/test/event_generator.h"
18 #include "ui/views/test/views_test_base.h" 18 #include "ui/views/test/views_test_base.h"
19 19
20 namespace { 20 namespace {
21 21
22 // A test delegate for a toolbar action view. 22 // A test delegate for a toolbar action view.
23 class TestToolbarActionViewDelegate : public ToolbarActionView::Delegate { 23 class TestToolbarActionViewDelegate : public ToolbarActionView::Delegate {
24 public: 24 public:
25 TestToolbarActionViewDelegate() : shown_in_menu_(false), 25 TestToolbarActionViewDelegate() : shown_in_menu_(false),
26 overflow_reference_view_(nullptr), 26 overflow_reference_view_(nullptr),
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 view.set_owned_by_client(); 211 view.set_owned_by_client();
212 view.SetBoundsRect(gfx::Rect(0, 0, 200, 20)); 212 view.SetBoundsRect(gfx::Rect(0, 0, 200, 20));
213 widget()->SetContentsView(&view); 213 widget()->SetContentsView(&view);
214 widget()->Show(); 214 widget()->Show();
215 215
216 // Check that the tooltip and accessible state of the view match the 216 // Check that the tooltip and accessible state of the view match the
217 // controller's. 217 // controller's.
218 base::string16 tooltip_test; 218 base::string16 tooltip_test;
219 EXPECT_TRUE(view.GetTooltipText(gfx::Point(), &tooltip_test)); 219 EXPECT_TRUE(view.GetTooltipText(gfx::Point(), &tooltip_test));
220 EXPECT_EQ(tooltip, tooltip_test); 220 EXPECT_EQ(tooltip, tooltip_test);
221 ui::AXViewState ax_state; 221 ui::AXNodeData ax_node_data;
222 view.GetAccessibleState(&ax_state); 222 view.GetAccessibleNodeData(&ax_node_data);
223 EXPECT_EQ(name, ax_state.name); 223 EXPECT_EQ(name, ax_node_data.GetString16Attribute(ui::AX_ATTR_NAME));
224 224
225 // The button should start in normal state, with no actions executed. 225 // The button should start in normal state, with no actions executed.
226 EXPECT_EQ(views::Button::STATE_NORMAL, view.state()); 226 EXPECT_EQ(views::Button::STATE_NORMAL, view.state());
227 EXPECT_EQ(0, controller.execute_action_count()); 227 EXPECT_EQ(0, controller.execute_action_count());
228 228
229 // Click the button. This should execute it. 229 // Click the button. This should execute it.
230 generator.MoveMouseTo(gfx::Point(10, 10)); 230 generator.MoveMouseTo(gfx::Point(10, 10));
231 generator.ClickLeftButton(); 231 generator.ClickLeftButton();
232 EXPECT_EQ(1, controller.execute_action_count()); 232 EXPECT_EQ(1, controller.execute_action_count());
233 233
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 // If the view isn't visible, the overflow button should be pressed for 277 // If the view isn't visible, the overflow button should be pressed for
278 // popups. 278 // popups.
279 view.SetVisible(false); 279 view.SetVisible(false);
280 controller.ShowPopup(true); 280 controller.ShowPopup(true);
281 EXPECT_EQ(views::Button::STATE_NORMAL, view.state()); 281 EXPECT_EQ(views::Button::STATE_NORMAL, view.state());
282 EXPECT_EQ(views::Button::STATE_PRESSED, overflow_button.state()); 282 EXPECT_EQ(views::Button::STATE_PRESSED, overflow_button.state());
283 controller.HidePopup(); 283 controller.HidePopup();
284 EXPECT_EQ(views::Button::STATE_NORMAL, view.state()); 284 EXPECT_EQ(views::Button::STATE_NORMAL, view.state());
285 EXPECT_EQ(views::Button::STATE_NORMAL, overflow_button.state()); 285 EXPECT_EQ(views::Button::STATE_NORMAL, overflow_button.state());
286 } 286 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/toolbar/toolbar_action_view.cc ('k') | chrome/browser/ui/views/toolbar/toolbar_button.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698