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

Side by Side Diff: ui/views/test/views_test_base.h

Issue 1175783003: Split out Ash dependency in app info dialog unittests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ViewEventTestBase will not play nice Created 5 years, 6 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
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 #ifndef UI_VIEWS_TEST_VIEWS_TEST_BASE_H_ 5 #ifndef UI_VIEWS_TEST_VIEWS_TEST_BASE_H_
6 #define UI_VIEWS_TEST_VIEWS_TEST_BASE_H_ 6 #define UI_VIEWS_TEST_VIEWS_TEST_BASE_H_
7 7
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 #include "testing/platform_test.h" 11 #include "testing/platform_test.h"
12 #include "ui/views/test/scoped_views_test_helper.h"
12 #include "ui/views/test/test_views_delegate.h" 13 #include "ui/views/test/test_views_delegate.h"
13 #include "ui/views/widget/widget.h" 14 #include "ui/views/widget/widget.h"
14 15
15 #if defined(OS_WIN) 16 #if defined(OS_WIN)
16 #include "ui/base/win/scoped_ole_initializer.h" 17 #include "ui/base/win/scoped_ole_initializer.h"
17 #endif 18 #endif
18 19
19 namespace views { 20 namespace views {
20 21
21 class ViewsTestHelper;
22
23 // A base class for views unit test. It creates a message loop necessary 22 // A base class for views unit test. It creates a message loop necessary
24 // to drive UI events and takes care of OLE initialization for windows. 23 // to drive UI events and takes care of OLE initialization for windows.
25 class ViewsTestBase : public PlatformTest { 24 class ViewsTestBase : public PlatformTest {
26 public: 25 public:
27 ViewsTestBase(); 26 ViewsTestBase();
28 ~ViewsTestBase() override; 27 ~ViewsTestBase() override;
29 28
30 // testing::Test: 29 // testing::Test:
31 void SetUp() override; 30 void SetUp() override;
32 void TearDown() override; 31 void TearDown() override;
33 32
34 void RunPendingMessages(); 33 void RunPendingMessages();
35 34
36 // Creates a widget of |type| with any platform specific data for use in 35 // Creates a widget of |type| with any platform specific data for use in
37 // cross-platform tests. 36 // cross-platform tests.
38 Widget::InitParams CreateParams(Widget::InitParams::Type type); 37 Widget::InitParams CreateParams(Widget::InitParams::Type type);
39 38
40 protected: 39 protected:
41 TestViewsDelegate* views_delegate() const { return views_delegate_.get(); } 40 TestViewsDelegate* views_delegate() const {
41 return test_helper_->views_delegate();
42 }
42 43
43 void set_views_delegate(scoped_ptr<TestViewsDelegate> views_delegate) { 44 void set_views_delegate(scoped_ptr<TestViewsDelegate> views_delegate) {
44 views_delegate_.swap(views_delegate); 45 DCHECK(!setup_called_);
46 views_delegate_for_setup_.swap(views_delegate);
45 } 47 }
46 48
47 base::MessageLoopForUI* message_loop() { return &message_loop_; } 49 base::MessageLoopForUI* message_loop() { return &message_loop_; }
48 50
49 // Returns a context view. In aura builds, this will be the 51 // Returns a context view. In aura builds, this will be the
50 // RootWindow. Everywhere else, NULL. 52 // RootWindow. Everywhere else, NULL.
51 gfx::NativeWindow GetContext(); 53 gfx::NativeWindow GetContext();
52 54
53 private: 55 private:
54 base::MessageLoopForUI message_loop_; 56 base::MessageLoopForUI message_loop_;
55 scoped_ptr<TestViewsDelegate> views_delegate_; 57 scoped_ptr<TestViewsDelegate> views_delegate_for_setup_;
56 scoped_ptr<ViewsTestHelper> test_helper_; 58 scoped_ptr<ScopedViewsTestHelper> test_helper_;
57 bool setup_called_; 59 bool setup_called_;
58 bool teardown_called_; 60 bool teardown_called_;
59 61
60 #if defined(OS_WIN) 62 #if defined(OS_WIN)
61 ui::ScopedOleInitializer ole_initializer_; 63 ui::ScopedOleInitializer ole_initializer_;
62 #endif 64 #endif
63 65
64 DISALLOW_COPY_AND_ASSIGN(ViewsTestBase); 66 DISALLOW_COPY_AND_ASSIGN(ViewsTestBase);
65 }; 67 };
66 68
67 } // namespace views 69 } // namespace views
68 70
69 #endif // UI_VIEWS_TEST_VIEWS_TEST_BASE_H_ 71 #endif // UI_VIEWS_TEST_VIEWS_TEST_BASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698