Commit 3b81c72f authored by Peter Kasting's avatar Peter Kasting Committed by Commit Bot

Call TearDown() from ~AshTestHelper().

This means callers only need to call TearDown() if they need to do
something between teardown and destruction, which most don't; and they
cannot fail to call TearDown() (and thus leave objects alive).  So it's
both simpler and safer.

Bug: none
Change-Id: Iba7ad30e64dca62d060b8c572253117d7952db3b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2124979
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Cr-Commit-Position: refs/heads/master@{#754709}
parent bac8e1eb
......@@ -153,7 +153,6 @@ void ShellBrowserMainParts::PostMainMessageLoopRun() {
example_app_list_client_.reset();
example_session_controller_client_.reset();
ash_test_helper_->TearDown();
ash_test_helper_.reset();
views_delegate_.reset();
......
......@@ -151,6 +151,9 @@ AshTestHelper::AshTestHelper(ConfigType config_type,
}
AshTestHelper::~AshTestHelper() {
if (app_list_test_helper_)
TearDown();
// Ensure the next test starts with a null display::Screen. This must be done
// here instead of in TearDown() since some tests test access to the Screen
// after the shell shuts down (which they use TearDown() to trigger).
......
......@@ -95,7 +95,8 @@ class AshTestHelper {
void SetUp();
// Tears down everything but the Screen instance, which some tests access
// after this point.
// after this point. This will be called automatically on destruction if it
// is not called manually earlier.
void TearDown();
aura::Window* GetContext();
......
......@@ -21,22 +21,16 @@ class AshTestHelperTest : public testing::Test {
void SetUp() override {
testing::Test::SetUp();
ash_test_helper_ = std::make_unique<AshTestHelper>();
ash_test_helper_->SetUp();
ash_test_helper_.SetUp();
}
void TearDown() override {
ash_test_helper_->TearDown();
testing::Test::TearDown();
}
AshTestHelper* ash_test_helper() { return ash_test_helper_.get(); }
AshTestHelper* ash_test_helper() { return &ash_test_helper_; }
private:
base::test::TaskEnvironment task_environment_{
base::test::TaskEnvironment::MainThreadType::UI};
std::unique_ptr<AshTestHelper> ash_test_helper_;
AshTestHelper ash_test_helper_;
DISALLOW_COPY_AND_ASSIGN(AshTestHelperTest);
};
......
......@@ -744,9 +744,7 @@ class RelaunchNotificationControllerPlatformImplTest : public ::testing::Test {
RelaunchNotificationControllerPlatformImplTest()
: task_environment_(base::test::TaskEnvironment::TimeSource::MOCK_TIME) {}
~RelaunchNotificationControllerPlatformImplTest() override {
ash_test_helper_.TearDown();
}
~RelaunchNotificationControllerPlatformImplTest() override = default;
void SetUp() override {
ash::AshTestHelper::InitParams init_params;
......
......@@ -138,8 +138,7 @@ void WaylandClientTestHelper::TearDownOnUIThread(base::WaitableEvent* event) {
wm_helper_.reset();
ash::Shell::Get()->session_controller()->NotifyChromeTerminating();
ash_test_helper_->TearDown();
ash_test_helper_ = nullptr;
ash_test_helper_.reset();
xdg_temp_dir_ = nullptr;
event->Signal();
}
......
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