| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 "ui/views/accessibility/native_view_accessibility.h" | 5 #include "ui/views/accessibility/native_view_accessibility.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "ui/accessibility/ax_node_data.h" | 9 #include "ui/accessibility/ax_node_data.h" |
| 10 #include "ui/gfx/geometry/rect_conversions.h" | 10 #include "ui/gfx/geometry/rect_conversions.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 button_->AddChildView(label_); | 51 button_->AddChildView(label_); |
| 52 label_accessibility_ = NativeViewAccessibility::Create(label_); | 52 label_accessibility_ = NativeViewAccessibility::Create(label_); |
| 53 | 53 |
| 54 widget_->GetContentsView()->AddChildView(button_); | 54 widget_->GetContentsView()->AddChildView(button_); |
| 55 widget_->Show(); | 55 widget_->Show(); |
| 56 } | 56 } |
| 57 | 57 |
| 58 void TearDown() override { | 58 void TearDown() override { |
| 59 if (!widget_->IsClosed()) | 59 if (!widget_->IsClosed()) |
| 60 widget_->Close(); | 60 widget_->Close(); |
| 61 button_accessibility_->Destroy(); | |
| 62 button_accessibility_ = NULL; | |
| 63 label_accessibility_->Destroy(); | |
| 64 label_accessibility_ = NULL; | |
| 65 ViewsTestBase::TearDown(); | 61 ViewsTestBase::TearDown(); |
| 66 } | 62 } |
| 67 | 63 |
| 68 protected: | 64 protected: |
| 69 views::Widget* widget_; | 65 views::Widget* widget_; |
| 70 TestButton* button_; | 66 TestButton* button_; |
| 71 NativeViewAccessibility* button_accessibility_; | 67 std::unique_ptr<NativeViewAccessibility> button_accessibility_; |
| 72 Label* label_; | 68 Label* label_; |
| 73 NativeViewAccessibility* label_accessibility_; | 69 std::unique_ptr<NativeViewAccessibility> label_accessibility_; |
| 74 }; | 70 }; |
| 75 | 71 |
| 76 TEST_F(NativeViewAccessibilityTest, RoleShouldMatch) { | 72 TEST_F(NativeViewAccessibilityTest, RoleShouldMatch) { |
| 77 EXPECT_EQ(ui::AX_ROLE_BUTTON, button_accessibility_->GetData().role); | 73 EXPECT_EQ(ui::AX_ROLE_BUTTON, button_accessibility_->GetData().role); |
| 78 EXPECT_EQ(ui::AX_ROLE_STATIC_TEXT, label_accessibility_->GetData().role); | 74 EXPECT_EQ(ui::AX_ROLE_STATIC_TEXT, label_accessibility_->GetData().role); |
| 79 } | 75 } |
| 80 | 76 |
| 81 TEST_F(NativeViewAccessibilityTest, BoundsShouldMatch) { | 77 TEST_F(NativeViewAccessibilityTest, BoundsShouldMatch) { |
| 82 gfx::Rect bounds = gfx::ToEnclosingRect( | 78 gfx::Rect bounds = gfx::ToEnclosingRect( |
| 83 button_accessibility_->GetData().location); | 79 button_accessibility_->GetData().location); |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 // During the destruction of parent, OnBlur will be called and change the | 216 // During the destruction of parent, OnBlur will be called and change the |
| 221 // visibility to false. | 217 // visibility to false. |
| 222 parent->SetVisible(true); | 218 parent->SetVisible(true); |
| 223 AXAuraObjCache* ax = AXAuraObjCache::GetInstance(); | 219 AXAuraObjCache* ax = AXAuraObjCache::GetInstance(); |
| 224 ax->GetOrCreate(widget.get()); | 220 ax->GetOrCreate(widget.get()); |
| 225 } | 221 } |
| 226 #endif | 222 #endif |
| 227 | 223 |
| 228 } // namespace test | 224 } // namespace test |
| 229 } // namespace views | 225 } // namespace views |
| OLD | NEW |