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

Side by Side Diff: chrome/test/base/view_event_test_base.cc

Issue 9664069: Move scoped_ole_initializer.h to ui/base/win and clean up ole initialization/uninitialization. (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
« no previous file with comments | « chrome/test/base/view_event_test_base.h ('k') | chrome_frame/test/net/fake_external_tab.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "chrome/test/base/view_event_test_base.h" 5 #include "chrome/test/base/view_event_test_base.h"
6 6
7 #if defined(OS_WIN)
8 #include <ole2.h>
9 #endif
10
11 #include "base/bind.h" 7 #include "base/bind.h"
12 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
13 #include "base/message_loop.h" 9 #include "base/message_loop.h"
14 #include "base/string_number_conversions.h" 10 #include "base/string_number_conversions.h"
15 #include "chrome/browser/automation/ui_controls.h" 11 #include "chrome/browser/automation/ui_controls.h"
16 #include "chrome/test/base/ui_test_utils.h" 12 #include "chrome/test/base/ui_test_utils.h"
17 #include "content/public/browser/browser_thread.h" 13 #include "content/public/browser/browser_thread.h"
18 #include "ui/gfx/compositor/test/compositor_test_support.h" 14 #include "ui/gfx/compositor/test/compositor_test_support.h"
19 #include "ui/views/view.h" 15 #include "ui/views/view.h"
20 #include "ui/views/widget/widget.h" 16 #include "ui/views/widget/widget.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 #endif 71 #endif
76 72
77 // If we're in a nested message loop, as is the case with menus, we 73 // If we're in a nested message loop, as is the case with menus, we
78 // need to quit twice. The second quit does that for us. Finish all 74 // need to quit twice. The second quit does that for us. Finish all
79 // pending UI events before posting closure because events it may be 75 // pending UI events before posting closure because events it may be
80 // executed before UI events are executed. 76 // executed before UI events are executed.
81 ui_controls::RunClosureAfterAllPendingUIEvents(MessageLoop::QuitClosure()); 77 ui_controls::RunClosureAfterAllPendingUIEvents(MessageLoop::QuitClosure());
82 } 78 }
83 79
84 void ViewEventTestBase::SetUp() { 80 void ViewEventTestBase::SetUp() {
85 #if defined(OS_WIN)
86 OleInitialize(NULL);
87 #endif
88 ui::CompositorTestSupport::Initialize(); 81 ui::CompositorTestSupport::Initialize();
89 #if defined(USE_AURA) 82 #if defined(USE_AURA)
90 ash::Shell::CreateInstance(NULL); 83 ash::Shell::CreateInstance(NULL);
91 #endif 84 #endif
92 window_ = views::Widget::CreateWindow(this); 85 window_ = views::Widget::CreateWindow(this);
93 } 86 }
94 87
95 void ViewEventTestBase::TearDown() { 88 void ViewEventTestBase::TearDown() {
96 if (window_) { 89 if (window_) {
97 #if defined(OS_WIN) && !defined(USE_AURA) 90 #if defined(OS_WIN) && !defined(USE_AURA)
98 DestroyWindow(window_->GetNativeWindow()); 91 DestroyWindow(window_->GetNativeWindow());
99 #else 92 #else
100 window_->Close(); 93 window_->Close();
101 ui_test_utils::RunAllPendingInMessageLoop(); 94 ui_test_utils::RunAllPendingInMessageLoop();
102 #endif 95 #endif
103 window_ = NULL; 96 window_ = NULL;
104 } 97 }
105 #if defined(USE_AURA) 98 #if defined(USE_AURA)
106 ash::Shell::DeleteInstance(); 99 ash::Shell::DeleteInstance();
107 aura::Env::DeleteInstance(); 100 aura::Env::DeleteInstance();
108 #endif 101 #endif
109 ui::CompositorTestSupport::Terminate(); 102 ui::CompositorTestSupport::Terminate();
110 #if defined(OS_WIN)
111 OleUninitialize();
112 #endif
113 } 103 }
114 104
115 bool ViewEventTestBase::CanResize() const { 105 bool ViewEventTestBase::CanResize() const {
116 return true; 106 return true;
117 } 107 }
118 108
119 views::View* ViewEventTestBase::GetContentsView() { 109 views::View* ViewEventTestBase::GetContentsView() {
120 if (!content_view_) { 110 if (!content_view_) {
121 // Wrap the real view (as returned by CreateContentsView) in a View so 111 // Wrap the real view (as returned by CreateContentsView) in a View so
122 // that we can customize the preferred size. 112 // that we can customize the preferred size.
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 dnd_thread_.reset(NULL); 168 dnd_thread_.reset(NULL);
179 } 169 }
180 170
181 void ViewEventTestBase::RunTestMethod(const base::Closure& task) { 171 void ViewEventTestBase::RunTestMethod(const base::Closure& task) {
182 StopBackgroundThread(); 172 StopBackgroundThread();
183 173
184 task.Run(); 174 task.Run();
185 if (HasFatalFailure()) 175 if (HasFatalFailure())
186 Done(); 176 Done();
187 } 177 }
OLDNEW
« no previous file with comments | « chrome/test/base/view_event_test_base.h ('k') | chrome_frame/test/net/fake_external_tab.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698