| OLD | NEW |
| 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 #import <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
| 6 | 6 |
| 7 #include "base/scoped_ptr.h" | 7 #include "base/scoped_ptr.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/browser/accessibility/browser_accessibility_cocoa.h" | 10 #include "chrome/browser/accessibility/browser_accessibility_cocoa.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 } | 40 } |
| 41 | 41 |
| 42 @end | 42 @end |
| 43 | 43 |
| 44 | 44 |
| 45 class BrowserAccessibilityTest : public CocoaTest { | 45 class BrowserAccessibilityTest : public CocoaTest { |
| 46 public: | 46 public: |
| 47 virtual void SetUp() { | 47 virtual void SetUp() { |
| 48 CocoaTest::SetUp(); | 48 CocoaTest::SetUp(); |
| 49 WebAccessibility root; | 49 WebAccessibility root; |
| 50 root.location.x = 0; | 50 root.location.set_width(500); |
| 51 root.location.y = 0; | 51 root.location.set_height(100); |
| 52 root.location.width = 500; | |
| 53 root.location.height = 100; | |
| 54 root.role = WebAccessibility::ROLE_WEB_AREA; | 52 root.role = WebAccessibility::ROLE_WEB_AREA; |
| 55 root.attributes[WebAccessibility::ATTR_HELP] = ASCIIToUTF16("HelpText"); | 53 root.attributes[WebAccessibility::ATTR_HELP] = ASCIIToUTF16("HelpText"); |
| 56 | 54 |
| 57 WebAccessibility child1; | 55 WebAccessibility child1; |
| 58 child1.name = ASCIIToUTF16("Child1"); | 56 child1.name = ASCIIToUTF16("Child1"); |
| 59 child1.location.x = 0; | 57 child1.location.set_width(250); |
| 60 child1.location.y = 0; | 58 child1.location.set_height(100); |
| 61 child1.location.width = 250; | |
| 62 child1.location.height = 100; | |
| 63 child1.role = WebAccessibility::ROLE_BUTTON; | 59 child1.role = WebAccessibility::ROLE_BUTTON; |
| 64 | 60 |
| 65 WebAccessibility child2; | 61 WebAccessibility child2; |
| 66 child2.location.x = 250; | 62 child2.location.set_x(250); |
| 67 child2.location.y = 0; | 63 child2.location.set_width(250); |
| 68 child2.location.width = 250; | 64 child2.location.setheight(100); |
| 69 child2.location.height = 100; | |
| 70 child2.role = WebAccessibility::ROLE_HEADING; | 65 child2.role = WebAccessibility::ROLE_HEADING; |
| 71 | 66 |
| 72 root.children.push_back(child1); | 67 root.children.push_back(child1); |
| 73 root.children.push_back(child2); | 68 root.children.push_back(child2); |
| 74 | 69 |
| 75 delegate_.reset([[MockAccessibilityDelegate alloc] init]); | 70 delegate_.reset([[MockAccessibilityDelegate alloc] init]); |
| 76 manager_.reset( | 71 manager_.reset( |
| 77 BrowserAccessibilityManager::Create(delegate_, root, NULL)); | 72 BrowserAccessibilityManager::Create(delegate_, root, NULL)); |
| 78 accessibility_.reset([manager_->GetRoot()->toBrowserAccessibilityCocoa() | 73 accessibility_.reset([manager_->GetRoot()->toBrowserAccessibilityCocoa() |
| 79 retain]); | 74 retain]); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 accessibilityAttributeValue:NSAccessibilityHelpAttribute]; | 111 accessibilityAttributeValue:NSAccessibilityHelpAttribute]; |
| 117 EXPECT_NSEQ(@"HelpText", helpText); | 112 EXPECT_NSEQ(@"HelpText", helpText); |
| 118 } | 113 } |
| 119 | 114 |
| 120 // Test querying for an invalid attribute to ensure it doesn't crash. | 115 // Test querying for an invalid attribute to ensure it doesn't crash. |
| 121 TEST_F(BrowserAccessibilityTest, InvalidAttributeTest) { | 116 TEST_F(BrowserAccessibilityTest, InvalidAttributeTest) { |
| 122 NSString* shouldBeNil = [accessibility_ | 117 NSString* shouldBeNil = [accessibility_ |
| 123 accessibilityAttributeValue:@"NSAnInvalidAttribute"]; | 118 accessibilityAttributeValue:@"NSAnInvalidAttribute"]; |
| 124 EXPECT_TRUE(shouldBeNil == nil); | 119 EXPECT_TRUE(shouldBeNil == nil); |
| 125 } | 120 } |
| OLD | NEW |