OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
| 6 #include "base/win/scoped_com_initializer.h" |
6 #include "base/win/scoped_comptr.h" | 7 #include "base/win/scoped_comptr.h" |
7 #include "content/browser/accessibility/browser_accessibility_manager.h" | 8 #include "content/browser/accessibility/browser_accessibility_manager.h" |
8 #include "content/browser/accessibility/browser_accessibility_win.h" | 9 #include "content/browser/accessibility/browser_accessibility_win.h" |
9 #include "content/common/accessibility_messages.h" | 10 #include "content/common/accessibility_messages.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
11 #include "ui/base/win/atl_module.h" | 12 #include "ui/base/win/atl_module.h" |
12 | 13 |
13 using content::AccessibilityNodeData; | 14 using content::AccessibilityNodeData; |
14 | 15 |
15 namespace { | 16 namespace { |
(...skipping 28 matching lines...) Expand all Loading... |
44 VARIANT CreateI4Variant(LONG value) { | 45 VARIANT CreateI4Variant(LONG value) { |
45 VARIANT variant = {0}; | 46 VARIANT variant = {0}; |
46 | 47 |
47 V_VT(&variant) = VT_I4; | 48 V_VT(&variant) = VT_I4; |
48 V_I4(&variant) = value; | 49 V_I4(&variant) = value; |
49 | 50 |
50 return variant; | 51 return variant; |
51 } | 52 } |
52 | 53 |
53 class BrowserAccessibilityTest : public testing::Test { | 54 class BrowserAccessibilityTest : public testing::Test { |
54 protected: | 55 public: |
| 56 BrowserAccessibilityTest() {} |
| 57 |
| 58 private: |
55 virtual void SetUp() { | 59 virtual void SetUp() { |
56 ui::win::CreateATLModuleIfNeeded(); | 60 ui::win::CreateATLModuleIfNeeded(); |
57 ::CoInitialize(NULL); | |
58 } | 61 } |
59 | 62 |
60 virtual void TearDown() { | 63 base::win::ScopedCOMInitializer com_initializer_; |
61 ::CoUninitialize(); | 64 |
62 } | 65 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibilityTest); |
63 }; | 66 }; |
64 | 67 |
65 // Test that BrowserAccessibilityManager correctly releases the tree of | 68 // Test that BrowserAccessibilityManager correctly releases the tree of |
66 // BrowserAccessibility instances upon delete. | 69 // BrowserAccessibility instances upon delete. |
67 TEST_F(BrowserAccessibilityTest, TestNoLeaks) { | 70 TEST_F(BrowserAccessibilityTest, TestNoLeaks) { |
68 // Create AccessibilityNodeData objects for a simple document tree, | 71 // Create AccessibilityNodeData objects for a simple document tree, |
69 // representing the accessibility information used to initialize | 72 // representing the accessibility information used to initialize |
70 // BrowserAccessibilityManager. | 73 // BrowserAccessibilityManager. |
71 AccessibilityNodeData button; | 74 AccessibilityNodeData button; |
72 button.id = 2; | 75 button.id = 2; |
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 EXPECT_EQ(S_OK, root_obj->get_hyperlinkIndex(14, &hyperlink_index)); | 531 EXPECT_EQ(S_OK, root_obj->get_hyperlinkIndex(14, &hyperlink_index)); |
529 EXPECT_EQ(0, hyperlink_index); | 532 EXPECT_EQ(0, hyperlink_index); |
530 EXPECT_EQ(S_OK, root_obj->get_hyperlinkIndex(30, &hyperlink_index)); | 533 EXPECT_EQ(S_OK, root_obj->get_hyperlinkIndex(30, &hyperlink_index)); |
531 EXPECT_EQ(1, hyperlink_index); | 534 EXPECT_EQ(1, hyperlink_index); |
532 | 535 |
533 // Delete the manager and test that all BrowserAccessibility instances are | 536 // Delete the manager and test that all BrowserAccessibility instances are |
534 // deleted. | 537 // deleted. |
535 delete manager; | 538 delete manager; |
536 ASSERT_EQ(0, CountedBrowserAccessibility::global_obj_count_); | 539 ASSERT_EQ(0, CountedBrowserAccessibility::global_obj_count_); |
537 } | 540 } |
OLD | NEW |