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

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

Issue 9535025: 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 aura::RootWindow* root_window = aura::RootWindow::GetInstance(); 124 root_window_.reset(new aura::RootWindow);
125 test_stacking_client_.reset( 125 test_stacking_client_.reset(
126 new aura::test::TestStackingClient(root_window)); 126 new aura::test::TestStackingClient(root_window_.get()));
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();
133 #endif 134 #endif
134 delete views::ViewsDelegate::views_delegate; 135 delete views::ViewsDelegate::views_delegate;
135 views::ViewsDelegate::views_delegate = NULL; 136 views::ViewsDelegate::views_delegate = NULL;
136 137
137 // The Widget's FocusManager is deleted using DeleteSoon - this 138 // The Widget's FocusManager is deleted using DeleteSoon - this
138 // forces it to be deleted now, so we don't have any memory leaks 139 // forces it to be deleted now, so we don't have any memory leaks
139 // when this method exits. 140 // when this method exits.
140 MessageLoop::current()->RunAllPending(); 141 MessageLoop::current()->RunAllPending();
141 } 142 }
142 143
(...skipping 15 matching lines...) Expand all
158 focus_event_count_++; 159 focus_event_count_++;
159 last_control_name_ = info->name(); 160 last_control_name_ = info->name();
160 last_control_context_ = info->context(); 161 last_control_context_ = info->context();
161 } 162 }
162 163
163 MessageLoopForUI message_loop_; 164 MessageLoopForUI message_loop_;
164 int focus_event_count_; 165 int focus_event_count_;
165 std::string last_control_name_; 166 std::string last_control_name_;
166 std::string last_control_context_; 167 std::string last_control_context_;
167 #if defined(USE_AURA) 168 #if defined(USE_AURA)
169 scoped_ptr<aura::RootWindow> root_window_;
168 scoped_ptr<aura::test::TestStackingClient> test_stacking_client_; 170 scoped_ptr<aura::test::TestStackingClient> test_stacking_client_;
169 #endif 171 #endif
170 }; 172 };
171 173
172 TEST_F(AccessibilityEventRouterViewsTest, TestFocusNotification) { 174 TEST_F(AccessibilityEventRouterViewsTest, TestFocusNotification) {
173 const char kButton1ASCII[] = "Button1"; 175 const char kButton1ASCII[] = "Button1";
174 const char kButton2ASCII[] = "Button2"; 176 const char kButton2ASCII[] = "Button2";
175 const char kButton3ASCII[] = "Button3"; 177 const char kButton3ASCII[] = "Button3";
176 const char kButton3NewASCII[] = "Button3New"; 178 const char kButton3NewASCII[] = "Button3New";
177 179
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 314
313 // Test that we got the event with the expected name and context. 315 // Test that we got the event with the expected name and context.
314 EXPECT_EQ(1, focus_event_count_); 316 EXPECT_EQ(1, focus_event_count_);
315 EXPECT_EQ(kButtonNameASCII, last_control_name_); 317 EXPECT_EQ(kButtonNameASCII, last_control_name_);
316 EXPECT_EQ(kAlertTextASCII, last_control_context_); 318 EXPECT_EQ(kAlertTextASCII, last_control_context_);
317 319
318 window->CloseNow(); 320 window->CloseNow();
319 } 321 }
320 322
321 #endif // defined(TOOLKIT_VIEWS) 323 #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