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

Side by Side Diff: ash/test/ash_test_helper.h

Issue 2296973002: Moves ash content specific tests into ash_content_unittests (Closed)
Patch Set: remove GetMessageLoop and merge Created 4 years, 3 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 ASH_TEST_ASH_TEST_HELPER_H_ 5 #ifndef ASH_TEST_ASH_TEST_HELPER_H_
6 #define ASH_TEST_ASH_TEST_HELPER_H_ 6 #define ASH_TEST_ASH_TEST_HELPER_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "ash/common/material_design/material_design_controller.h" 10 #include "ash/common/material_design/material_design_controller.h"
11 #include "ash/common/test/material_design_controller_test_api.h" 11 #include "ash/common/test/material_design_controller_test_api.h"
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 14
15 namespace aura { 15 namespace aura {
16 class Window; 16 class Window;
17 } // namespace aura 17 } // namespace aura
18 18
19 namespace base {
20 class MessageLoopForUI;
21 } // namespace base
22
23 namespace ui { 19 namespace ui {
24 class ScopedAnimationDurationScaleMode; 20 class ScopedAnimationDurationScaleMode;
25 } // namespace ui 21 } // namespace ui
26 22
27 namespace views { 23 namespace views {
28 class ViewsDelegate; 24 class ViewsDelegate;
29 } 25 }
30 26
31 namespace ash { 27 namespace ash {
32 class ShellContentState;
33 namespace test { 28 namespace test {
34 29
30 class AshTestEnvironment;
35 class TestScreenshotDelegate; 31 class TestScreenshotDelegate;
36 class TestShellContentState;
37 class TestShellDelegate; 32 class TestShellDelegate;
38 class TestSessionStateDelegate; 33 class TestSessionStateDelegate;
39 34
40 // A helper class that does common initialization required for Ash. Creates a 35 // A helper class that does common initialization required for Ash. Creates a
41 // root window and an ash::Shell instance with a test delegate. 36 // root window and an ash::Shell instance with a test delegate.
42 class AshTestHelper { 37 class AshTestHelper {
43 public: 38 public:
44 explicit AshTestHelper(base::MessageLoopForUI* message_loop); 39 explicit AshTestHelper(AshTestEnvironment* ash_test_environment);
45 ~AshTestHelper(); 40 ~AshTestHelper();
46 41
47 // Creates the ash::Shell and performs associated initialization. Set 42 // Creates the ash::Shell and performs associated initialization. Set
48 // |start_session| to true if the user should log in before the test is run. 43 // |start_session| to true if the user should log in before the test is run.
49 // |material_mode| determines the material design mode to be used for the 44 // |material_mode| determines the material design mode to be used for the
50 // tests. If |material_mode| is UNINITIALIZED, the value from command line 45 // tests. If |material_mode| is UNINITIALIZED, the value from command line
51 // switches is used. 46 // switches is used.
52 void SetUp(bool start_session, MaterialDesignController::Mode material_mode); 47 void SetUp(bool start_session, MaterialDesignController::Mode material_mode);
53 48
54 // Destroys the ash::Shell and performs associated cleanup. 49 // Destroys the ash::Shell and performs associated cleanup.
55 void TearDown(); 50 void TearDown();
56 51
57 // Returns a root Window. Usually this is the active root Window, but that 52 // Returns a root Window. Usually this is the active root Window, but that
58 // method can return NULL sometimes, and in those cases, we fall back on the 53 // method can return NULL sometimes, and in those cases, we fall back on the
59 // primary root Window. 54 // primary root Window.
60 aura::Window* CurrentContext(); 55 aura::Window* CurrentContext();
61 56
62 void RunAllPendingInMessageLoop(); 57 void RunAllPendingInMessageLoop();
63 58
64 static TestSessionStateDelegate* GetTestSessionStateDelegate(); 59 static TestSessionStateDelegate* GetTestSessionStateDelegate();
65 60
66 base::MessageLoopForUI* message_loop() { return message_loop_; }
67 TestShellDelegate* test_shell_delegate() { return test_shell_delegate_; } 61 TestShellDelegate* test_shell_delegate() { return test_shell_delegate_; }
68 void set_test_shell_delegate(TestShellDelegate* test_shell_delegate) { 62 void set_test_shell_delegate(TestShellDelegate* test_shell_delegate) {
69 test_shell_delegate_ = test_shell_delegate; 63 test_shell_delegate_ = test_shell_delegate;
70 } 64 }
71 TestScreenshotDelegate* test_screenshot_delegate() { 65 TestScreenshotDelegate* test_screenshot_delegate() {
72 return test_screenshot_delegate_; 66 return test_screenshot_delegate_;
73 } 67 }
74 TestShellContentState* test_shell_content_state() { 68
75 return test_shell_content_state_; 69 AshTestEnvironment* ash_test_environment() { return ash_test_environment_; }
76 }
77 void set_content_state(ShellContentState* content_state) {
78 content_state_ = content_state;
79 }
80 70
81 // True if the running environment supports multiple displays, 71 // True if the running environment supports multiple displays,
82 // or false otherwise (e.g. win8 bot). 72 // or false otherwise (e.g. win8 bot).
83 static bool SupportsMultipleDisplays(); 73 static bool SupportsMultipleDisplays();
84 74
85 // True if the running environment supports host window resize, 75 // True if the running environment supports host window resize,
86 // or false otherwise (e.g. win8 bot). 76 // or false otherwise (e.g. win8 bot).
87 static bool SupportsHostWindowResize(); 77 static bool SupportsHostWindowResize();
88 78
89 private: 79 private:
90 base::MessageLoopForUI* message_loop_; // Not owned. 80 AshTestEnvironment* ash_test_environment_; // Not owned.
91 TestShellDelegate* test_shell_delegate_; // Owned by ash::Shell. 81 TestShellDelegate* test_shell_delegate_; // Owned by ash::Shell.
92 std::unique_ptr<ui::ScopedAnimationDurationScaleMode> zero_duration_mode_; 82 std::unique_ptr<ui::ScopedAnimationDurationScaleMode> zero_duration_mode_;
93 83
94 // Owned by ash::AcceleratorController 84 // Owned by ash::AcceleratorController
95 TestScreenshotDelegate* test_screenshot_delegate_; 85 TestScreenshotDelegate* test_screenshot_delegate_;
96 86
97 std::unique_ptr<views::ViewsDelegate> views_delegate_; 87 std::unique_ptr<views::ViewsDelegate> views_delegate_;
98 88
99 // An implementation of ShellContentState supplied by the user prior to
100 // SetUp().
101 ShellContentState* content_state_;
102 // If |content_state_| is not set prior to SetUp(), this value will be
103 // set to an instance of TestShellContentState created by this class. If
104 // |content_state_| is non-null, this will be nullptr.
105 TestShellContentState* test_shell_content_state_;
106
107 #if defined(OS_CHROMEOS) 89 #if defined(OS_CHROMEOS)
108 // Check if DBus Thread Manager was initialized here. 90 // Check if DBus Thread Manager was initialized here.
109 bool dbus_thread_manager_initialized_; 91 bool dbus_thread_manager_initialized_;
110 // Check if Bluez DBus Manager was initialized here. 92 // Check if Bluez DBus Manager was initialized here.
111 bool bluez_dbus_manager_initialized_; 93 bool bluez_dbus_manager_initialized_;
112 #endif 94 #endif
113 95
114 std::unique_ptr<test::MaterialDesignControllerTestAPI> material_design_state_; 96 std::unique_ptr<test::MaterialDesignControllerTestAPI> material_design_state_;
115 97
116 DISALLOW_COPY_AND_ASSIGN(AshTestHelper); 98 DISALLOW_COPY_AND_ASSIGN(AshTestHelper);
117 }; 99 };
118 100
119 } // namespace test 101 } // namespace test
120 } // namespace ash 102 } // namespace ash
121 103
122 #endif // ASH_TEST_ASH_TEST_HELPER_H_ 104 #endif // ASH_TEST_ASH_TEST_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698