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

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

Issue 9564023: Revert 124461 - Remove the singleton instance get/delete methods from RootWindow (yay) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 9 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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.h" 7 #include "base/message_loop.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/accessibility_extension_api.h" 10 #include "chrome/browser/accessibility/accessibility_extension_api.h"
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 ui::AccessibilityTypes::Role role_; 114 ui::AccessibilityTypes::Role role_;
115 }; 115 };
116 116
117 class AccessibilityEventRouterViewsTest 117 class AccessibilityEventRouterViewsTest
118 : public testing::Test, 118 : public testing::Test,
119 public content::NotificationObserver { 119 public content::NotificationObserver {
120 public: 120 public:
121 virtual void SetUp() { 121 virtual void SetUp() {
122 views::ViewsDelegate::views_delegate = new AccessibilityViewsDelegate(); 122 views::ViewsDelegate::views_delegate = new AccessibilityViewsDelegate();
123 #if defined(USE_AURA) 123 #if defined(USE_AURA)
124 root_window_.reset(new aura::RootWindow); 124 aura::RootWindow* root_window = aura::RootWindow::GetInstance();
125 test_stacking_client_.reset( 125 test_stacking_client_.reset(
126 new aura::test::TestStackingClient(root_window_.get())); 126 new aura::test::TestStackingClient(root_window));
127 #endif 127 #endif
128 } 128 }
129 129
130 virtual void TearDown() { 130 virtual void TearDown() {
131 #if defined(USE_AURA) 131 #if defined(USE_AURA)
132 test_stacking_client_.reset(); 132 test_stacking_client_.reset();
133 root_window_.reset();
134 #endif 133 #endif
135 delete views::ViewsDelegate::views_delegate; 134 delete views::ViewsDelegate::views_delegate;
136 views::ViewsDelegate::views_delegate = NULL; 135 views::ViewsDelegate::views_delegate = NULL;
137 136
138 // The Widget's FocusManager is deleted using DeleteSoon - this 137 // The Widget's FocusManager is deleted using DeleteSoon - this
139 // forces it to be deleted now, so we don't have any memory leaks 138 // forces it to be deleted now, so we don't have any memory leaks
140 // when this method exits. 139 // when this method exits.
141 MessageLoop::current()->RunAllPending(); 140 MessageLoop::current()->RunAllPending();
142 } 141 }
143 142
(...skipping 15 matching lines...) Expand all
159 focus_event_count_++; 158 focus_event_count_++;
160 last_control_name_ = info->name(); 159 last_control_name_ = info->name();
161 last_control_context_ = info->context(); 160 last_control_context_ = info->context();
162 } 161 }
163 162
164 MessageLoopForUI message_loop_; 163 MessageLoopForUI message_loop_;
165 int focus_event_count_; 164 int focus_event_count_;
166 std::string last_control_name_; 165 std::string last_control_name_;
167 std::string last_control_context_; 166 std::string last_control_context_;
168 #if defined(USE_AURA) 167 #if defined(USE_AURA)
169 scoped_ptr<aura::RootWindow> root_window_;
170 scoped_ptr<aura::test::TestStackingClient> test_stacking_client_; 168 scoped_ptr<aura::test::TestStackingClient> test_stacking_client_;
171 #endif 169 #endif
172 }; 170 };
173 171
174 TEST_F(AccessibilityEventRouterViewsTest, TestFocusNotification) { 172 TEST_F(AccessibilityEventRouterViewsTest, TestFocusNotification) {
175 const char kButton1ASCII[] = "Button1"; 173 const char kButton1ASCII[] = "Button1";
176 const char kButton2ASCII[] = "Button2"; 174 const char kButton2ASCII[] = "Button2";
177 const char kButton3ASCII[] = "Button3"; 175 const char kButton3ASCII[] = "Button3";
178 const char kButton3NewASCII[] = "Button3New"; 176 const char kButton3NewASCII[] = "Button3New";
179 177
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 312
315 // Test that we got the event with the expected name and context. 313 // Test that we got the event with the expected name and context.
316 EXPECT_EQ(1, focus_event_count_); 314 EXPECT_EQ(1, focus_event_count_);
317 EXPECT_EQ(kButtonNameASCII, last_control_name_); 315 EXPECT_EQ(kButtonNameASCII, last_control_name_);
318 EXPECT_EQ(kAlertTextASCII, last_control_context_); 316 EXPECT_EQ(kAlertTextASCII, last_control_context_);
319 317
320 window->CloseNow(); 318 window->CloseNow();
321 } 319 }
322 320
323 #endif // defined(TOOLKIT_VIEWS) 321 #endif // defined(TOOLKIT_VIEWS)
OLDNEW
« no previous file with comments | « chrome/browser/notifications/desktop_notifications_unittest.cc ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698