OLD | NEW |
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 "ui/views/widget/native_widget_win.h" | 5 #include "ui/views/widget/native_widget_win.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 #include "ui/base/win/scoped_ole_initializer.h" |
11 | 12 |
12 namespace views { | 13 namespace views { |
13 namespace { | 14 namespace { |
14 | 15 |
15 class NativeWidgetWinTest : public testing::Test { | 16 class NativeWidgetWinTest : public testing::Test { |
16 public: | 17 public: |
17 NativeWidgetWinTest() { | 18 NativeWidgetWinTest() {} |
18 OleInitialize(NULL); | 19 ~NativeWidgetWinTest() {} |
19 } | |
20 | |
21 ~NativeWidgetWinTest() { | |
22 OleUninitialize(); | |
23 } | |
24 | 20 |
25 virtual void TearDown() { | 21 virtual void TearDown() { |
26 // Flush the message loop because we have pending release tasks | 22 // Flush the message loop because we have pending release tasks |
27 // and these tasks if un-executed would upset Valgrind. | 23 // and these tasks if un-executed would upset Valgrind. |
28 RunPendingMessages(); | 24 RunPendingMessages(); |
29 } | 25 } |
30 | 26 |
31 // Create a simple widget win. The caller is responsible for taking ownership | 27 // Create a simple widget win. The caller is responsible for taking ownership |
32 // of the returned value. | 28 // of the returned value. |
33 NativeWidgetWin* CreateNativeWidgetWin(); | 29 NativeWidgetWin* CreateNativeWidgetWin(); |
34 | 30 |
35 void RunPendingMessages() { | 31 void RunPendingMessages() { |
36 message_loop_.RunAllPending(); | 32 message_loop_.RunAllPending(); |
37 } | 33 } |
38 | 34 |
39 private: | 35 private: |
40 MessageLoopForUI message_loop_; | 36 MessageLoopForUI message_loop_; |
| 37 ui::ScopedOleInitializer ole_initializer_; |
41 | 38 |
42 DISALLOW_COPY_AND_ASSIGN(NativeWidgetWinTest); | 39 DISALLOW_COPY_AND_ASSIGN(NativeWidgetWinTest); |
43 }; | 40 }; |
44 | 41 |
45 NativeWidgetWin* NativeWidgetWinTest::CreateNativeWidgetWin() { | 42 NativeWidgetWin* NativeWidgetWinTest::CreateNativeWidgetWin() { |
46 scoped_ptr<Widget> widget(new Widget); | 43 scoped_ptr<Widget> widget(new Widget); |
47 Widget::InitParams params(Widget::InitParams::TYPE_POPUP); | 44 Widget::InitParams params(Widget::InitParams::TYPE_POPUP); |
48 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 45 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
49 params.bounds = gfx::Rect(50, 50, 650, 650); | 46 params.bounds = gfx::Rect(50, 50, 650, 650); |
50 widget->Init(params); | 47 widget->Init(params); |
(...skipping 26 matching lines...) Expand all Loading... |
77 EXPECT_FALSE(window->IsZoomed()); | 74 EXPECT_FALSE(window->IsZoomed()); |
78 EXPECT_FALSE(window->IsActive()); | 75 EXPECT_FALSE(window->IsActive()); |
79 | 76 |
80 // Cleanup. | 77 // Cleanup. |
81 window->CloseNow(); | 78 window->CloseNow(); |
82 window2->CloseNow(); | 79 window2->CloseNow(); |
83 } | 80 } |
84 | 81 |
85 } // namespace | 82 } // namespace |
86 } // namespace views | 83 } // namespace views |
OLD | NEW |