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

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

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

Powered by Google App Engine
This is Rietveld 408576698