Use a TestBrowserThreadBundle in the DeviceSettingsTestBase.

Lots of policy tests inherit from that class to reuse common setup code.
The recent work on cloud policy for extensions wired a new class to some
of the existing ones that posts a cleanup task to the IO thread, and
DeviceSettingsTestBase wasn't mocking that thread; so these tests started
leaking at shutdown.

The TestBrowserThreadBundle sets up the UI and FILE threads that the tests
were expecting as well as the other common threads, which makes these tests
more robust.

TBR=pastarmovj@chromium.org
BUG=None

Review URL: https://codereview.chromium.org/348713004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@278648 0039d316-1c4b-4281-b951-d872f2087c98
parent 1b5cd520
......@@ -177,10 +177,10 @@ void CloudExternalDataPolicyObserverTest::SetUp() {
new DeviceLocalAccountPolicyService(&device_settings_test_helper_,
&device_settings_service_,
&cros_settings_,
loop_.message_loop_proxy(),
loop_.message_loop_proxy(),
loop_.message_loop_proxy(),
loop_.message_loop_proxy(),
base::MessageLoopProxy::current(),
base::MessageLoopProxy::current(),
base::MessageLoopProxy::current(),
base::MessageLoopProxy::current(),
NULL));
url_fetcher_factory_.set_remove_fetcher_on_delete(true);
......
......@@ -69,7 +69,7 @@ class DeviceCloudPolicyManagerChromeOSTest
protected:
DeviceCloudPolicyManagerChromeOSTest()
: state_keys_broker_(&fake_session_manager_client_,
loop_.message_loop_proxy()),
base::MessageLoopProxy::current()),
store_(NULL) {
EXPECT_CALL(mock_statistics_provider_,
GetMachineStatistic(_, _))
......@@ -97,13 +97,14 @@ class DeviceCloudPolicyManagerChromeOSTest
// DBusThreadManager is set up in DeviceSettingsTestBase::SetUp().
install_attributes_.reset(new EnterpriseInstallAttributes(
chromeos::DBusThreadManager::Get()->GetCryptohomeClient()));
store_ = new DeviceCloudPolicyStoreChromeOS(&device_settings_service_,
store_ =
new DeviceCloudPolicyStoreChromeOS(&device_settings_service_,
install_attributes_.get(),
loop_.message_loop_proxy());
base::MessageLoopProxy::current());
manager_.reset(new DeviceCloudPolicyManagerChromeOS(
make_scoped_ptr(store_),
loop_.message_loop_proxy(),
loop_.message_loop_proxy(),
base::MessageLoopProxy::current(),
base::MessageLoopProxy::current(),
install_attributes_.get(),
&state_keys_broker_));
......@@ -114,7 +115,7 @@ class DeviceCloudPolicyManagerChromeOSTest
// OAuth tokens, then writes the token to local state, encrypting it
// first with methods in CryptohomeTokenEncryptor.
request_context_getter_ = new net::TestURLRequestContextGetter(
loop_.message_loop_proxy());
base::MessageLoopProxy::current());
TestingBrowserProcess::GetGlobal()->SetSystemRequestContext(
request_context_getter_.get());
TestingBrowserProcess::GetGlobal()->SetLocalState(&local_state_);
......
......@@ -9,6 +9,7 @@
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop_proxy.h"
#include "base/run_loop.h"
#include "chrome/browser/chromeos/policy/enterprise_install_attributes.h"
#include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h"
......@@ -36,11 +37,12 @@ class DeviceCloudPolicyStoreChromeOSTest
protected:
DeviceCloudPolicyStoreChromeOSTest()
: fake_cryptohome_client_(new chromeos::FakeCryptohomeClient()),
install_attributes_(new EnterpriseInstallAttributes(
fake_cryptohome_client_.get())),
store_(new DeviceCloudPolicyStoreChromeOS(&device_settings_service_,
install_attributes_(
new EnterpriseInstallAttributes(fake_cryptohome_client_.get())),
store_(new DeviceCloudPolicyStoreChromeOS(
&device_settings_service_,
install_attributes_.get(),
loop_.message_loop_proxy())) {
base::MessageLoopProxy::current())) {
fake_cryptohome_client_->Init(NULL /* no dbus::Bus */);
}
......@@ -103,7 +105,7 @@ class DeviceCloudPolicyStoreChromeOSTest
store_.reset(
new DeviceCloudPolicyStoreChromeOS(&device_settings_service_,
install_attributes_.get(),
loop_.message_loop_proxy()));
base::MessageLoopProxy::current()));
}
scoped_ptr<chromeos::FakeCryptohomeClient> fake_cryptohome_client_;
......
......@@ -159,12 +159,11 @@ void DeviceLocalAccountPolicyServiceTestBase::CreatePolicyService() {
&device_settings_test_helper_,
&device_settings_service_,
&cros_settings_,
loop_.message_loop_proxy(),
base::MessageLoopProxy::current(),
extension_cache_task_runner_,
loop_.message_loop_proxy(),
loop_.message_loop_proxy(),
new net::TestURLRequestContextGetter(
base::MessageLoop::current()->message_loop_proxy())));
base::MessageLoopProxy::current(),
base::MessageLoopProxy::current(),
new net::TestURLRequestContextGetter(base::MessageLoopProxy::current())));
}
void DeviceLocalAccountPolicyServiceTestBase::
......
......@@ -203,9 +203,7 @@ ScopedDeviceSettingsTestHelper::~ScopedDeviceSettingsTestHelper() {
}
DeviceSettingsTestBase::DeviceSettingsTestBase()
: ui_thread_(content::BrowserThread::UI, &loop_),
file_thread_(content::BrowserThread::FILE, &loop_),
user_manager_(new FakeUserManager()),
: user_manager_(new FakeUserManager()),
user_manager_enabler_(user_manager_),
owner_key_util_(new MockOwnerKeyUtil()),
fake_dbus_thread_manager_(new FakeDBusThreadManager()) {
......@@ -221,7 +219,7 @@ void DeviceSettingsTestBase::SetUp() {
chromeos::DBusThreadManager::InitializeForTesting(fake_dbus_thread_manager_);
NetworkHandler::Initialize();
loop_.RunUntilIdle();
base::RunLoop().RunUntilIdle();
device_policy_.payload().mutable_metrics_enabled()->set_metrics_enabled(
false);
......
......@@ -22,7 +22,7 @@
#include "chrome/browser/chromeos/settings/device_settings_test_helper.h"
#include "chrome/browser/chromeos/settings/mock_owner_key_util.h"
#include "chromeos/dbus/session_manager_client.h"
#include "content/public/test/test_browser_thread.h"
#include "content/public/test/test_browser_thread_bundle.h"
#include "testing/gtest/include/gtest/gtest.h"
class TestingProfile;
......@@ -179,9 +179,7 @@ class DeviceSettingsTestBase : public testing::Test {
void InitOwner(const std::string& user_id, bool tpm_is_ready);
base::MessageLoopForUI loop_;
content::TestBrowserThread ui_thread_;
content::TestBrowserThread file_thread_;
content::TestBrowserThreadBundle thread_bundle_;
policy::DevicePolicyBuilder device_policy_;
......
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