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

Side by Side Diff: ui/views/accessibility/native_view_accessibility_unittest.cc

Issue 420653003: MacViews: Accessibility bridge (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix build Created 6 years, 4 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
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/strings/utf_string_conversions.h"
6 #include "ui/accessibility/ax_view_state.h"
7 #include "ui/views/accessibility/native_view_accessibility.h"
8 #include "ui/views/controls/button/button.h"
9 #include "ui/views/controls/label.h"
10 #include "ui/views/test/views_test_base.h"
11
12 namespace views {
13 namespace test {
14
15 class NativeViewAccessibilityTest;
16
17 namespace {
18
19 class TestButton : public Button {
20 public:
21 TestButton() : Button(NULL) {}
22 };
23
24 } // namespace
25
26 class NativeViewAccessibilityTest : public ViewsTestBase {
27 public:
28 NativeViewAccessibilityTest() {}
29 virtual ~NativeViewAccessibilityTest() {}
30
31 virtual void SetUp() OVERRIDE {
32 ViewsTestBase::SetUp();
33 button_.reset(new TestButton());
34 button_->SetSize(gfx::Size(20, 20));
35 button_accessibility_ = NativeViewAccessibility::Create(button_.get());
36
37 label_.reset(new Label);
38 button_->AddChildView(label_.get());
39 label_accessibility_ = NativeViewAccessibility::Create(label_.get());
40 }
41
42 virtual void TearDown() OVERRIDE {
43 button_accessibility_->Destroy();
44 button_accessibility_ = NULL;
45 label_accessibility_->Destroy();
46 label_accessibility_ = NULL;
47 ViewsTestBase::TearDown();
48 }
49
50 protected:
51 scoped_ptr<TestButton> button_;
52 NativeViewAccessibility* button_accessibility_;
53 scoped_ptr<Label> label_;
54 NativeViewAccessibility* label_accessibility_;
55 };
56
57 TEST_F(NativeViewAccessibilityTest, RoleShouldMatch) {
58 EXPECT_EQ(ui::AX_ROLE_BUTTON, button_accessibility_->GetData()->role);
59 EXPECT_EQ(ui::AX_ROLE_STATIC_TEXT, label_accessibility_->GetData()->role);
60 }
61
62 TEST_F(NativeViewAccessibilityTest, BoundsShouldMatch) {
63 gfx::Rect bounds = button_accessibility_->GetData()->location;
64 bounds.Offset(button_accessibility_->GetGlobalCoordinateOffset());
65 EXPECT_EQ(button_->GetBoundsInScreen(), bounds);
66 }
67
68 TEST_F(NativeViewAccessibilityTest, LabelIsChildOfButton) {
69 EXPECT_EQ(1, button_accessibility_->GetChildCount());
70 EXPECT_EQ(label_->GetNativeViewAccessible(),
71 button_accessibility_->ChildAtIndex(0));
72 EXPECT_EQ(button_->GetNativeViewAccessible(),
73 label_accessibility_->GetParent());
74 }
75
76 } // namespace test
77 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698