Commit e6ad64af authored by Peter Kasting's avatar Peter Kasting Committed by Commit Bot

Construct AshTestHelper during AshTestBase::SetUp().

This allows setting command-line flags before AshTestHelper is
constructed.

Bug: none
Change-Id: Iab006b3b144948f7a982a6b591dc5e4527b2feb3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2125179Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Xiyuan Xia <xiyuan@chromium.org>
Auto-Submit: Peter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#754522}
parent 694e12fb
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include "ash/public/cpp/assistant/assistant_state.h" #include "ash/public/cpp/assistant/assistant_state.h"
#include "ash/public/cpp/test/assistant_test_api.h" #include "ash/public/cpp/test/assistant_test_api.h"
#include "ash/shell.h" #include "ash/shell.h"
#include "ash/test/ash_test_helper.h"
#include "base/run_loop.h" #include "base/run_loop.h"
#include "base/test/task_environment.h" #include "base/test/task_environment.h"
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "ash/system/bluetooth/tray_bluetooth_helper.h" #include "ash/system/bluetooth/tray_bluetooth_helper.h"
#include "ash/test/ash_test_base.h" #include "ash/test/ash_test_base.h"
#include "base/bind_helpers.h" #include "base/bind_helpers.h"
#include "base/command_line.h"
#include "base/run_loop.h" #include "base/run_loop.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "chromeos/constants/chromeos_switches.h" #include "chromeos/constants/chromeos_switches.h"
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "ash/test/ash_test_base.h" #include "ash/test/ash_test_base.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/strings/string16.h" #include "base/strings/string16.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_piece.h" #include "base/strings/string_piece.h"
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
......
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
#include "ash/system/unified/unified_system_tray_model.h" #include "ash/system/unified/unified_system_tray_model.h"
#include "ash/test/ash_test_base.h" #include "ash/test/ash_test_base.h"
#include "base/test/scoped_feature_list.h" #include "base/test/scoped_feature_list.h"
#include "ui/accessibility/ax_enums.mojom.h"
#include "ui/accessibility/ax_node_data.h"
#include "ui/views/view_observer.h" #include "ui/views/view_observer.h"
namespace ash { namespace ash {
......
...@@ -151,7 +151,8 @@ void AshTestBase::SetUp(std::unique_ptr<TestShellDelegate> delegate) { ...@@ -151,7 +151,8 @@ void AshTestBase::SetUp(std::unique_ptr<TestShellDelegate> delegate) {
params.start_session = start_session_; params.start_session = start_session_;
params.delegate = std::move(delegate); params.delegate = std::move(delegate);
params.local_state = local_state(); params.local_state = local_state();
ash_test_helper_.SetUp(std::move(params)); ash_test_helper_ = std::make_unique<AshTestHelper>();
ash_test_helper_->SetUp(std::move(params));
Shell::GetPrimaryRootWindow()->Show(); Shell::GetPrimaryRootWindow()->Show();
Shell::GetPrimaryRootWindow()->GetHost()->Show(); Shell::GetPrimaryRootWindow()->GetHost()->Show();
...@@ -179,7 +180,7 @@ void AshTestBase::TearDown() { ...@@ -179,7 +180,7 @@ void AshTestBase::TearDown() {
// Flush the message loop to finish pending release tasks. // Flush the message loop to finish pending release tasks.
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
ash_test_helper_.TearDown(); ash_test_helper_->TearDown();
event_generator_.reset(); event_generator_.reset();
// Some tests set an internal display id, // Some tests set an internal display id,
...@@ -236,7 +237,7 @@ void AshTestBase::UpdateDisplay(const std::string& display_specs) { ...@@ -236,7 +237,7 @@ void AshTestBase::UpdateDisplay(const std::string& display_specs) {
} }
aura::Window* AshTestBase::GetContext() { aura::Window* AshTestBase::GetContext() {
return ash_test_helper_.GetContext(); return ash_test_helper_->GetContext();
} }
// static // static
...@@ -382,15 +383,15 @@ TestScreenshotDelegate* AshTestBase::GetScreenshotDelegate() { ...@@ -382,15 +383,15 @@ TestScreenshotDelegate* AshTestBase::GetScreenshotDelegate() {
} }
TestSessionControllerClient* AshTestBase::GetSessionControllerClient() { TestSessionControllerClient* AshTestBase::GetSessionControllerClient() {
return ash_test_helper_.test_session_controller_client(); return ash_test_helper_->test_session_controller_client();
} }
TestSystemTrayClient* AshTestBase::GetSystemTrayClient() { TestSystemTrayClient* AshTestBase::GetSystemTrayClient() {
return ash_test_helper_.system_tray_client(); return ash_test_helper_->system_tray_client();
} }
AppListTestHelper* AshTestBase::GetAppListTestHelper() { AppListTestHelper* AshTestBase::GetAppListTestHelper() {
return ash_test_helper_.app_list_test_helper(); return ash_test_helper_->app_list_test_helper();
} }
void AshTestBase::CreateUserSessions(int n) { void AshTestBase::CreateUserSessions(int n) {
...@@ -558,7 +559,7 @@ display::Display AshTestBase::GetPrimaryDisplay() const { ...@@ -558,7 +559,7 @@ display::Display AshTestBase::GetPrimaryDisplay() const {
} }
display::Display AshTestBase::GetSecondaryDisplay() const { display::Display AshTestBase::GetSecondaryDisplay() const {
return ash_test_helper_.GetSecondaryDisplay(); return ash_test_helper_->GetSecondaryDisplay();
} }
} // namespace ash } // namespace ash
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
#include "ash/public/cpp/app_types.h" #include "ash/public/cpp/app_types.h"
#include "ash/public/cpp/shell_window_ids.h" #include "ash/public/cpp/shell_window_ids.h"
#include "ash/session/test_session_controller_client.h" #include "ash/session/test_session_controller_client.h"
#include "ash/test/ash_test_helper.h"
#include "ash/wm/desks/desks_util.h" #include "ash/wm/desks/desks_util.h"
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "base/macros.h" #include "base/macros.h"
...@@ -67,6 +66,7 @@ class WidgetDelegate; ...@@ -67,6 +66,7 @@ class WidgetDelegate;
namespace ash { namespace ash {
class AppListTestHelper; class AppListTestHelper;
class AshTestHelper;
class Shelf; class Shelf;
class TestScreenshotDelegate; class TestScreenshotDelegate;
class TestShellDelegate; class TestShellDelegate;
...@@ -221,7 +221,7 @@ class AshTestBase : public testing::Test { ...@@ -221,7 +221,7 @@ class AshTestBase : public testing::Test {
return task_environment_.get(); return task_environment_.get();
} }
TestingPrefServiceSimple* local_state() { return &local_state_; } TestingPrefServiceSimple* local_state() { return &local_state_; }
AshTestHelper* ash_test_helper() { return &ash_test_helper_; } AshTestHelper* ash_test_helper() { return ash_test_helper_.get(); }
TestScreenshotDelegate* GetScreenshotDelegate(); TestScreenshotDelegate* GetScreenshotDelegate();
...@@ -299,8 +299,8 @@ class AshTestBase : public testing::Test { ...@@ -299,8 +299,8 @@ class AshTestBase : public testing::Test {
// A pref service used for local state. // A pref service used for local state.
TestingPrefServiceSimple local_state_; TestingPrefServiceSimple local_state_;
// Must be constructed after |task_environment_| but before SetUp(). // Must be constructed after |task_environment_|.
AshTestHelper ash_test_helper_; std::unique_ptr<AshTestHelper> ash_test_helper_;
std::unique_ptr<ui::test::EventGenerator> event_generator_; std::unique_ptr<ui::test::EventGenerator> event_generator_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment