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

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

Issue 145293007: ui: No more TestCompositor. Use NullDraw contexts in unit tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: testsnulldraw: Created 6 years, 10 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 16 matching lines...) Expand all
27 #include "ui/views/widget/widget.h" 27 #include "ui/views/widget/widget.h"
28 #include "ui/views/widget/widget_delegate.h" 28 #include "ui/views/widget/widget_delegate.h"
29 29
30 #if defined(OS_WIN) 30 #if defined(OS_WIN)
31 #include "ui/base/win/scoped_ole_initializer.h" 31 #include "ui/base/win/scoped_ole_initializer.h"
32 #endif 32 #endif
33 33
34 #if defined(USE_AURA) 34 #if defined(USE_AURA)
35 #include "ui/aura/root_window.h" 35 #include "ui/aura/root_window.h"
36 #include "ui/aura/test/aura_test_helper.h" 36 #include "ui/aura/test/aura_test_helper.h"
37 #include "ui/compositor/test/context_factories_for_test.h"
37 #endif 38 #endif
38 39
39 using base::ASCIIToUTF16; 40 using base::ASCIIToUTF16;
40 41
41 class AccessibilityViewsDelegate : public views::TestViewsDelegate { 42 class AccessibilityViewsDelegate : public views::TestViewsDelegate {
42 public: 43 public:
43 AccessibilityViewsDelegate() {} 44 AccessibilityViewsDelegate() {}
44 virtual ~AccessibilityViewsDelegate() {} 45 virtual ~AccessibilityViewsDelegate() {}
45 46
46 // Overridden from views::TestViewsDelegate: 47 // Overridden from views::TestViewsDelegate:
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 public: 100 public:
100 AccessibilityEventRouterViewsTest() : control_event_count_(0) { 101 AccessibilityEventRouterViewsTest() : control_event_count_(0) {
101 } 102 }
102 103
103 virtual void SetUp() { 104 virtual void SetUp() {
104 #if defined(OS_WIN) 105 #if defined(OS_WIN)
105 ole_initializer_.reset(new ui::ScopedOleInitializer()); 106 ole_initializer_.reset(new ui::ScopedOleInitializer());
106 #endif 107 #endif
107 views::ViewsDelegate::views_delegate = new AccessibilityViewsDelegate(); 108 views::ViewsDelegate::views_delegate = new AccessibilityViewsDelegate();
108 #if defined(USE_AURA) 109 #if defined(USE_AURA)
110 // The ContextFactory must exist before any Compositors are created.
111 bool enable_pixel_output = false;
112 ui::InitializeContextFactoryForTests(enable_pixel_output);
113
109 aura_test_helper_.reset(new aura::test::AuraTestHelper(&message_loop_)); 114 aura_test_helper_.reset(new aura::test::AuraTestHelper(&message_loop_));
110 bool allow_test_contexts = true; 115 aura_test_helper_->SetUp();
111 aura_test_helper_->SetUp(allow_test_contexts);
112 #endif // USE_AURA 116 #endif // USE_AURA
113 EnableAccessibilityAndListenToFocusNotifications(); 117 EnableAccessibilityAndListenToFocusNotifications();
114 } 118 }
115 119
116 virtual void TearDown() { 120 virtual void TearDown() {
117 ClearCallback(); 121 ClearCallback();
118 #if defined(USE_AURA) 122 #if defined(USE_AURA)
119 aura_test_helper_->TearDown(); 123 aura_test_helper_->TearDown();
124 ui::TerminateContextFactoryForTests();
120 #endif 125 #endif
121 delete views::ViewsDelegate::views_delegate; 126 delete views::ViewsDelegate::views_delegate;
122 views::ViewsDelegate::views_delegate = NULL; 127 views::ViewsDelegate::views_delegate = NULL;
123 128
124 // The Widget's FocusManager is deleted using DeleteSoon - this 129 // The Widget's FocusManager is deleted using DeleteSoon - this
125 // forces it to be deleted now, so we don't have any memory leaks 130 // forces it to be deleted now, so we don't have any memory leaks
126 // when this method exits. 131 // when this method exits.
127 base::MessageLoop::current()->RunUntilIdle(); 132 base::MessageLoop::current()->RunUntilIdle();
128 133
129 #if defined(OS_WIN) 134 #if defined(OS_WIN)
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 499
495 AccessibilityEventRouterViews::RecursiveGetMenuItemIndexAndCount( 500 AccessibilityEventRouterViews::RecursiveGetMenuItemIndexAndCount(
496 menu_container, 501 menu_container,
497 menu->GetMenuItemByID(kTestCases[i].command_id), 502 menu->GetMenuItemByID(kTestCases[i].command_id),
498 &index, 503 &index,
499 &count); 504 &count);
500 EXPECT_EQ(kTestCases[i].expected_index, index) << "Case " << i; 505 EXPECT_EQ(kTestCases[i].expected_index, index) << "Case " << i;
501 EXPECT_EQ(kTestCases[i].expected_count, count) << "Case " << i; 506 EXPECT_EQ(kTestCases[i].expected_count, count) << "Case " << i;
502 } 507 }
503 } 508 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698