Commit cf61ce5c authored by Yury Khmel's avatar Yury Khmel Committed by Commit Bot

Reduce using wallpaper test client in unit tests.

It is possible to drop using wallpaper test client for the set of unit
tests where wallpaper test client is used to prevent crash from the
fake user manager.

Test: git cl try
Bug: N/A
Change-Id: I7a788656fe0558841523744dc5ada3a1d5ffde9b
Reviewed-on: https://chromium-review.googlesource.com/957788
Commit-Queue: Yury Khmel <khmel@google.com>
Reviewed-by: default avatarMichael Wasserman <msw@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Reviewed-by: default avatarHidehiko Abe <hidehiko@chromium.org>
Cr-Commit-Position: refs/heads/master@{#542554}
parent f217fa52
......@@ -35,8 +35,6 @@
#include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h"
#include "chrome/browser/ui/app_list/arc/arc_app_test.h"
#include "chrome/browser/ui/ash/multi_user/multi_user_util.h"
#include "chrome/browser/ui/ash/test_wallpaper_controller.h"
#include "chrome/browser/ui/ash/wallpaper_controller_client.h"
#include "chrome/test/base/testing_profile.h"
#include "chromeos/chromeos_switches.h"
#include "chromeos/dbus/dbus_thread_manager.h"
......@@ -265,15 +263,10 @@ class ArcSessionManagerTestBase : public testing::Test {
StartPreferenceSyncing();
ASSERT_FALSE(arc_session_manager_->enable_requested());
wallpaper_controller_client_ =
std::make_unique<WallpaperControllerClient>();
wallpaper_controller_client_->InitForTesting(
test_wallpaper_controller_.CreateInterfacePtr());
}
void TearDown() override {
arc_session_manager_->Shutdown();
wallpaper_controller_client_.reset();
profile_.reset();
arc_session_manager_.reset();
arc_service_manager_.reset();
......@@ -320,8 +313,6 @@ class ArcSessionManagerTestBase : public testing::Test {
std::unique_ptr<ArcSessionManager> arc_session_manager_;
user_manager::ScopedUserManager user_manager_enabler_;
base::ScopedTempDir temp_dir_;
std::unique_ptr<WallpaperControllerClient> wallpaper_controller_client_;
TestWallpaperController test_wallpaper_controller_;
DISALLOW_COPY_AND_ASSIGN(ArcSessionManagerTestBase);
};
......
......@@ -24,8 +24,6 @@
#include "chrome/browser/policy/profile_policy_connector.h"
#include "chrome/browser/policy/profile_policy_connector_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/ash/test_wallpaper_controller.h"
#include "chrome/browser/ui/ash/wallpaper_controller_client.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
#include "chrome/test/base/testing_profile_manager.h"
......@@ -194,22 +192,20 @@ class ChromeArcUtilTest : public testing::Test {
// Used by FakeChromeUserManager.
chromeos::DeviceSettingsService::Initialize();
chromeos::CrosSettings::Initialize();
wallpaper_controller_client_ =
std::make_unique<WallpaperControllerClient>();
wallpaper_controller_client_->InitForTesting(
test_wallpaper_controller_.CreateInterfacePtr());
profile_ = profile_manager_->CreateTestingProfile(kTestProfileName);
}
void TearDown() override {
// Avoid retries, let the next test start safely.
ResetArcAllowedCheckForTesting(profile_);
profile_manager_->DeleteTestingProfile(kTestProfileName);
profile_ = nullptr;
command_line_.reset();
wallpaper_controller_client_.reset();
chromeos::CrosSettings::Shutdown();
chromeos::DeviceSettingsService::Shutdown();
user_manager_enabler_.reset();
profile_manager_.reset();
command_line_.reset();
}
TestingProfile* profile() { return profile_; }
......@@ -227,8 +223,6 @@ class ChromeArcUtilTest : public testing::Test {
}
private:
std::unique_ptr<WallpaperControllerClient> wallpaper_controller_client_;
TestWallpaperController test_wallpaper_controller_;
std::unique_ptr<base::test::ScopedCommandLine> command_line_;
content::TestBrowserThreadBundle thread_bundle_;
base::ScopedTempDir data_dir_;
......
......@@ -237,7 +237,11 @@ void FakeChromeUserManager::RemoveUser(
user_manager::RemoveUserDelegate* delegate) {}
void FakeChromeUserManager::RemoveUserFromList(const AccountId& account_id) {
WallpaperControllerClient::Get()->RemoveUserWallpaper(account_id);
WallpaperControllerClient* const wallpaper_client =
WallpaperControllerClient::Get();
// |wallpaper_client| could be nullptr in tests.
if (wallpaper_client)
wallpaper_client->RemoveUserWallpaper(account_id);
chromeos::ProfileHelper::Get()->RemoveUserFromListForTesting(account_id);
const user_manager::UserList::iterator it =
......
......@@ -10,8 +10,6 @@
#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h"
#include "chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.h"
#include "chrome/browser/ui/ash/test_wallpaper_controller.h"
#include "chrome/browser/ui/ash/wallpaper_controller_client.h"
#include "chrome/test/base/browser_with_test_window_test.h"
#include "chrome/test/base/test_browser_window_aura.h"
#include "chrome/test/base/testing_profile_manager.h"
......@@ -66,17 +64,12 @@ class BrowserFinderChromeOSTest : public BrowserWithTestWindowTest {
test_account_id2_ = AccountId::FromUserEmail(kTestAccount2);
BrowserWithTestWindowTest::SetUp();
profile_manager()->SetLoggedIn(true);
wallpaper_controller_client_ =
std::make_unique<WallpaperControllerClient>();
wallpaper_controller_client_->InitForTesting(
test_wallpaper_controller_.CreateInterfacePtr());
second_profile_ = CreateMultiUserProfile(test_account_id2_);
}
void TearDown() override {
MultiUserWindowManager::DeleteInstance();
BrowserWithTestWindowTest::TearDown();
wallpaper_controller_client_.reset();
}
TestingProfile* CreateProfile() override {
......@@ -90,10 +83,6 @@ class BrowserFinderChromeOSTest : public BrowserWithTestWindowTest {
chromeos::FakeChromeUserManager* fake_user_manager_;
user_manager::ScopedUserManager user_manager_enabler_;
std::unique_ptr<WallpaperControllerClient> wallpaper_controller_client_;
TestWallpaperController test_wallpaper_controller_;
DISALLOW_COPY_AND_ASSIGN(BrowserFinderChromeOSTest);
};
......
......@@ -14,8 +14,6 @@
#include "chrome/browser/chromeos/login/users/multi_profile_user_controller_delegate.h"
#include "chrome/browser/chromeos/settings/cros_settings.h"
#include "chrome/browser/chromeos/settings/device_settings_service.h"
#include "chrome/browser/ui/ash/test_wallpaper_controller.h"
#include "chrome/browser/ui/ash/wallpaper_controller_client.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile_manager.h"
#include "components/proximity_auth/screenlock_bridge.h"
......@@ -69,16 +67,11 @@ class SigninPrepareUserListTest : public ash::AshTestBase,
chromeos::DeviceSettingsService::Initialize();
chromeos::CrosSettings::Initialize();
wallpaper_controller_client_ =
std::make_unique<WallpaperControllerClient>();
wallpaper_controller_client_->InitForTesting(
test_wallpaper_controller_.CreateInterfacePtr());
}
void TearDown() override {
controller_.reset();
profile_manager_.reset();
wallpaper_controller_client_.reset();
ash::AshTestBase::TearDown();
}
......@@ -90,8 +83,6 @@ class SigninPrepareUserListTest : public ash::AshTestBase,
std::unique_ptr<TestingProfileManager> profile_manager_;
std::map<std::string, proximity_auth::mojom::AuthType> user_auth_type_map;
std::unique_ptr<MultiProfileUserController> controller_;
std::unique_ptr<WallpaperControllerClient> wallpaper_controller_client_;
TestWallpaperController test_wallpaper_controller_;
DISALLOW_COPY_AND_ASSIGN(SigninPrepareUserListTest);
};
......
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