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

Side by Side Diff: chrome/browser/ui/views/accessibility/accessibility_event_router_views_unittest.cc

Issue 273073002: Changes code using Compositor to pass in ContextFactory (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix tooltip on chromeos Created 6 years, 7 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
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 <string> 5 #include <string>
6 6
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/accessibility/accessibility_extension_api.h" 10 #include "chrome/browser/accessibility/accessibility_extension_api.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 AccessibilityViewsDelegate() {} 45 AccessibilityViewsDelegate() {}
46 virtual ~AccessibilityViewsDelegate() {} 46 virtual ~AccessibilityViewsDelegate() {}
47 47
48 // Overridden from views::TestViewsDelegate: 48 // Overridden from views::TestViewsDelegate:
49 virtual void NotifyAccessibilityEvent( 49 virtual void NotifyAccessibilityEvent(
50 views::View* view, ui::AXEvent event_type) OVERRIDE { 50 views::View* view, ui::AXEvent event_type) OVERRIDE {
51 AccessibilityEventRouterViews::GetInstance()->HandleAccessibilityEvent( 51 AccessibilityEventRouterViews::GetInstance()->HandleAccessibilityEvent(
52 view, event_type); 52 view, event_type);
53 } 53 }
54 54
55 private:
55 DISALLOW_COPY_AND_ASSIGN(AccessibilityViewsDelegate); 56 DISALLOW_COPY_AND_ASSIGN(AccessibilityViewsDelegate);
56 }; 57 };
57 58
58 class AccessibilityWindowDelegate : public views::WidgetDelegate { 59 class AccessibilityWindowDelegate : public views::WidgetDelegate {
59 public: 60 public:
60 explicit AccessibilityWindowDelegate(views::View* contents) 61 explicit AccessibilityWindowDelegate(views::View* contents)
61 : contents_(contents) { } 62 : contents_(contents) { }
62 63
63 // Overridden from views::WidgetDelegate: 64 // Overridden from views::WidgetDelegate:
64 virtual void DeleteDelegate() OVERRIDE { delete this; } 65 virtual void DeleteDelegate() OVERRIDE { delete this; }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 class AccessibilityEventRouterViewsTest 100 class AccessibilityEventRouterViewsTest
100 : public testing::Test { 101 : public testing::Test {
101 public: 102 public:
102 AccessibilityEventRouterViewsTest() : control_event_count_(0) { 103 AccessibilityEventRouterViewsTest() : control_event_count_(0) {
103 } 104 }
104 105
105 virtual void SetUp() { 106 virtual void SetUp() {
106 #if defined(OS_WIN) 107 #if defined(OS_WIN)
107 ole_initializer_.reset(new ui::ScopedOleInitializer()); 108 ole_initializer_.reset(new ui::ScopedOleInitializer());
108 #endif 109 #endif
109 views::ViewsDelegate::views_delegate = new AccessibilityViewsDelegate(); 110 views_delegate_.reset(new AccessibilityViewsDelegate);
110 #if defined(USE_AURA) 111 #if defined(USE_AURA)
111 // The ContextFactory must exist before any Compositors are created. 112 // The ContextFactory must exist before any Compositors are created.
112 bool enable_pixel_output = false; 113 bool enable_pixel_output = false;
113 ui::InitializeContextFactoryForTests(enable_pixel_output); 114 ui::ContextFactory* context_factory =
115 ui::InitializeContextFactoryForTests(enable_pixel_output);
114 116
115 aura_test_helper_.reset(new aura::test::AuraTestHelper(&message_loop_)); 117 aura_test_helper_.reset(new aura::test::AuraTestHelper(&message_loop_));
116 aura_test_helper_->SetUp(); 118 aura_test_helper_->SetUp(context_factory);
119 views_delegate_->set_context_factory(context_factory);
117 new wm::DefaultActivationClient(aura_test_helper_->root_window()); 120 new wm::DefaultActivationClient(aura_test_helper_->root_window());
118 #endif // USE_AURA 121 #endif // USE_AURA
119 EnableAccessibilityAndListenToFocusNotifications(); 122 EnableAccessibilityAndListenToFocusNotifications();
120 } 123 }
121 124
122 virtual void TearDown() { 125 virtual void TearDown() {
123 ClearCallback(); 126 ClearCallback();
124 #if defined(USE_AURA) 127 #if defined(USE_AURA)
125 aura_test_helper_->TearDown(); 128 aura_test_helper_->TearDown();
126 ui::TerminateContextFactoryForTests(); 129 ui::TerminateContextFactoryForTests();
127 #endif 130 #endif
128 delete views::ViewsDelegate::views_delegate; 131 views_delegate_.reset();
129 views::ViewsDelegate::views_delegate = NULL;
130 132
131 // The Widget's FocusManager is deleted using DeleteSoon - this 133 // The Widget's FocusManager is deleted using DeleteSoon - this
132 // forces it to be deleted now, so we don't have any memory leaks 134 // forces it to be deleted now, so we don't have any memory leaks
133 // when this method exits. 135 // when this method exits.
134 base::MessageLoop::current()->RunUntilIdle(); 136 base::MessageLoop::current()->RunUntilIdle();
135 137
136 #if defined(OS_WIN) 138 #if defined(OS_WIN)
137 ole_initializer_.reset(); 139 ole_initializer_.reset();
138 #endif 140 #endif
139 } 141 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 std::string last_control_type_; 187 std::string last_control_type_;
186 std::string last_control_name_; 188 std::string last_control_name_;
187 std::string last_control_context_; 189 std::string last_control_context_;
188 TestingProfile profile_; 190 TestingProfile profile_;
189 #if defined(OS_WIN) 191 #if defined(OS_WIN)
190 scoped_ptr<ui::ScopedOleInitializer> ole_initializer_; 192 scoped_ptr<ui::ScopedOleInitializer> ole_initializer_;
191 #endif 193 #endif
192 #if defined(USE_AURA) 194 #if defined(USE_AURA)
193 scoped_ptr<aura::test::AuraTestHelper> aura_test_helper_; 195 scoped_ptr<aura::test::AuraTestHelper> aura_test_helper_;
194 #endif 196 #endif
197 scoped_ptr<AccessibilityViewsDelegate> views_delegate_;
195 }; 198 };
196 199
197 TEST_F(AccessibilityEventRouterViewsTest, TestFocusNotification) { 200 TEST_F(AccessibilityEventRouterViewsTest, TestFocusNotification) {
198 const char kButton1ASCII[] = "Button1"; 201 const char kButton1ASCII[] = "Button1";
199 const char kButton2ASCII[] = "Button2"; 202 const char kButton2ASCII[] = "Button2";
200 const char kButton3ASCII[] = "Button3"; 203 const char kButton3ASCII[] = "Button3";
201 const char kButton3NewASCII[] = "Button3New"; 204 const char kButton3NewASCII[] = "Button3New";
202 205
203 // Create a contents view with 3 buttons. 206 // Create a contents view with 3 buttons.
204 views::View* contents = new views::View(); 207 views::View* contents = new views::View();
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 504
502 AccessibilityEventRouterViews::RecursiveGetMenuItemIndexAndCount( 505 AccessibilityEventRouterViews::RecursiveGetMenuItemIndexAndCount(
503 menu_container, 506 menu_container,
504 menu->GetMenuItemByID(kTestCases[i].command_id), 507 menu->GetMenuItemByID(kTestCases[i].command_id),
505 &index, 508 &index,
506 &count); 509 &count);
507 EXPECT_EQ(kTestCases[i].expected_index, index) << "Case " << i; 510 EXPECT_EQ(kTestCases[i].expected_index, index) << "Case " << i;
508 EXPECT_EQ(kTestCases[i].expected_count, count) << "Case " << i; 511 EXPECT_EQ(kTestCases[i].expected_count, count) << "Case " << i;
509 } 512 }
510 } 513 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/ash/ash_init.cc ('k') | chrome/browser/ui/views/frame/browser_desktop_window_tree_host_x11.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698