diff options
74 files changed, 745 insertions, 1255 deletions
diff --git a/ash/display/projecting_observer_chromeos_unittest.cc b/ash/display/projecting_observer_chromeos_unittest.cc index 3a72551..1de18ed 100644 --- a/ash/display/projecting_observer_chromeos_unittest.cc +++ b/ash/display/projecting_observer_chromeos_unittest.cc @@ -5,7 +5,7 @@ #include "ash/display/projecting_observer_chromeos.h" #include "base/memory/scoped_vector.h" -#include "chromeos/dbus/fake_dbus_thread_manager.h" +#include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/dbus/fake_power_manager_client.h" #include "testing/gtest/include/gtest/gtest.h" #include "ui/display/chromeos/test/test_display_snapshot.h" @@ -40,15 +40,10 @@ ui::DisplayConfigurator::DisplayStateList CreateOutputs( class ProjectingObserverTest : public testing::Test { public: ProjectingObserverTest() : observer_(new ProjectingObserver()) { - chromeos::FakeDBusThreadManager* dbus_manager = - new chromeos::FakeDBusThreadManager(); fake_power_client_ = new chromeos::FakePowerManagerClient(); - dbus_manager->SetPowerManagerClient( + chromeos::DBusThreadManager::GetSetterForTesting()->SetPowerManagerClient( scoped_ptr<chromeos::PowerManagerClient>(fake_power_client_)); - - // Takes ownership of |dbus_manager|. - chromeos::DBusThreadManager::InitializeForTesting(dbus_manager); } virtual ~ProjectingObserverTest() { diff --git a/ash/system/chromeos/network/network_state_notifier_unittest.cc b/ash/system/chromeos/network/network_state_notifier_unittest.cc index 1032bf7..31107ec 100644 --- a/ash/system/chromeos/network/network_state_notifier_unittest.cc +++ b/ash/system/chromeos/network/network_state_notifier_unittest.cc @@ -41,7 +41,7 @@ class NetworkStateNotifierTest : public AshTestBase { virtual ~NetworkStateNotifierTest() {} virtual void SetUp() OVERRIDE { - DBusThreadManager::InitializeWithStub(); + DBusThreadManager::Initialize(); chromeos::LoginState::Initialize(); SetupDefaultShillState(); chromeos::NetworkHandler::Initialize(); diff --git a/ash/system/chromeos/power/power_status_unittest.cc b/ash/system/chromeos/power/power_status_unittest.cc index 2884d35..e5bee7e 100644 --- a/ash/system/chromeos/power/power_status_unittest.cc +++ b/ash/system/chromeos/power/power_status_unittest.cc @@ -37,7 +37,7 @@ class PowerStatusTest : public testing::Test { virtual ~PowerStatusTest() {} virtual void SetUp() OVERRIDE { - chromeos::DBusThreadManager::InitializeWithStub(); + chromeos::DBusThreadManager::Initialize(); PowerStatus::Initialize(); power_status_ = PowerStatus::Get(); test_observer_.reset(new TestObserver); diff --git a/ash/test/ash_test_helper.cc b/ash/test/ash_test_helper.cc index b9f8ece..86a50d5 100644 --- a/ash/test/ash_test_helper.cc +++ b/ash/test/ash_test_helper.cc @@ -81,7 +81,7 @@ void AshTestHelper::SetUp(bool start_session) { #if defined(OS_CHROMEOS) // Create DBusThreadManager for testing. if (!chromeos::DBusThreadManager::IsInitialized()) { - chromeos::DBusThreadManager::InitializeWithStub(); + chromeos::DBusThreadManager::Initialize(); dbus_thread_manager_initialized_ = true; } // Create CrasAudioHandler for testing since g_browser_process is not diff --git a/athena/test/athena_test_helper.cc b/athena/test/athena_test_helper.cc index b2353d5..251311b 100644 --- a/athena/test/athena_test_helper.cc +++ b/athena/test/athena_test_helper.cc @@ -48,7 +48,7 @@ void AthenaTestHelper::SetUp(ui::ContextFactory* context_factory) { base::Thread::Options options(base::MessageLoop::TYPE_IO, 0); file_thread_->StartWithOptions(options); - chromeos::DBusThreadManager::InitializeWithStub(); + chromeos::DBusThreadManager::Initialize(); ui::InitializeInputMethodForTesting(); aura::Env::CreateInstance(true); aura::Env::GetInstance()->set_context_factory(context_factory); diff --git a/chrome/browser/apps/app_browsertest.cc b/chrome/browser/apps/app_browsertest.cc index 5952fdba..c859db2 100644 --- a/chrome/browser/apps/app_browsertest.cc +++ b/chrome/browser/apps/app_browsertest.cc @@ -52,7 +52,6 @@ #include "chrome/browser/chromeos/login/users/mock_user_manager.h" #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" #include "chromeos/dbus/dbus_thread_manager.h" -#include "chromeos/dbus/fake_dbus_thread_manager.h" #include "chromeos/dbus/fake_power_manager_client.h" #endif @@ -1231,13 +1230,9 @@ class RestartDeviceTest : public PlatformAppBrowserTest { virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { PlatformAppBrowserTest::SetUpInProcessBrowserTestFixture(); - chromeos::FakeDBusThreadManager* dbus_manager = - new chromeos::FakeDBusThreadManager; - dbus_manager->SetFakeClients(); power_manager_client_ = new chromeos::FakePowerManagerClient; - dbus_manager->SetPowerManagerClient( + chromeos::DBusThreadManager::GetSetterForTesting()->SetPowerManagerClient( scoped_ptr<chromeos::PowerManagerClient>(power_manager_client_)); - chromeos::DBusThreadManager::SetInstanceForTesting(dbus_manager); } virtual void SetUpOnMainThread() OVERRIDE { diff --git a/chrome/browser/browsing_data/browsing_data_remover_unittest.cc b/chrome/browser/browsing_data/browsing_data_remover_unittest.cc index 6d45317..1dc599b 100644 --- a/chrome/browser/browsing_data/browsing_data_remover_unittest.cc +++ b/chrome/browser/browsing_data/browsing_data_remover_unittest.cc @@ -59,7 +59,6 @@ #include "chrome/browser/chromeos/settings/cros_settings.h" #include "chrome/browser/chromeos/settings/device_settings_service.h" #include "chromeos/dbus/dbus_thread_manager.h" -#include "chromeos/dbus/fake_dbus_thread_manager.h" #include "chromeos/dbus/mock_cryptohome_client.h" #endif @@ -1765,13 +1764,12 @@ TEST_F(BrowsingDataRemoverTest, ContentProtectionPlatformKeysRemoval) { mock_user_manager->SetActiveUser("test@example.com"); chromeos::ScopedUserManagerEnabler user_manager_enabler(mock_user_manager); - chromeos::FakeDBusThreadManager* fake_dbus_manager = - new chromeos::FakeDBusThreadManager; + scoped_ptr<chromeos::DBusThreadManagerSetter> dbus_setter = + chromeos::DBusThreadManager::GetSetterForTesting(); chromeos::MockCryptohomeClient* cryptohome_client = new chromeos::MockCryptohomeClient; - fake_dbus_manager->SetCryptohomeClient( + dbus_setter->SetCryptohomeClient( scoped_ptr<chromeos::CryptohomeClient>(cryptohome_client)); - chromeos::DBusThreadManager::InitializeForTesting(fake_dbus_manager); // Expect exactly one call. No calls means no attempt to delete keys and more // than one call means a significant performance problem. diff --git a/chrome/browser/chromeos/chrome_browser_main_chromeos.cc b/chrome/browser/chromeos/chrome_browser_main_chromeos.cc index 5e1de04..b9250c6 100644 --- a/chrome/browser/chromeos/chrome_browser_main_chromeos.cc +++ b/chrome/browser/chromeos/chrome_browser_main_chromeos.cc @@ -91,7 +91,6 @@ #include "chromeos/cryptohome/homedir_methods.h" #include "chromeos/cryptohome/system_salt_getter.h" #include "chromeos/dbus/dbus_thread_manager.h" -#include "chromeos/dbus/power_policy_controller.h" #include "chromeos/dbus/session_manager_client.h" #include "chromeos/disks/disk_mount_manager.h" #include "chromeos/ime/ime_keyboard.h" diff --git a/chrome/browser/chromeos/customization_document_unittest.cc b/chrome/browser/chromeos/customization_document_unittest.cc index 6f3e63b..2590fbe 100644 --- a/chrome/browser/chromeos/customization_document_unittest.cc +++ b/chrome/browser/chromeos/customization_document_unittest.cc @@ -226,7 +226,7 @@ class ServicesCustomizationDocumentTest : public testing::Test { chromeos::system::StatisticsProvider::SetTestProvider( &mock_statistics_provider_); - DBusThreadManager::InitializeWithStub(); + DBusThreadManager::Initialize(); NetworkHandler::Initialize(); RunUntilIdle(); const NetworkState* default_network = diff --git a/chrome/browser/chromeos/login/auth/cryptohome_authenticator_unittest.cc b/chrome/browser/chromeos/login/auth/cryptohome_authenticator_unittest.cc index 8918f93..5a54d0a 100644 --- a/chrome/browser/chromeos/login/auth/cryptohome_authenticator_unittest.cc +++ b/chrome/browser/chromeos/login/auth/cryptohome_authenticator_unittest.cc @@ -28,8 +28,8 @@ #include "chromeos/chromeos_switches.h" #include "chromeos/cryptohome/mock_async_method_caller.h" #include "chromeos/cryptohome/system_salt_getter.h" +#include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/dbus/fake_cryptohome_client.h" -#include "chromeos/dbus/fake_dbus_thread_manager.h" #include "chromeos/login/auth/key.h" #include "chromeos/login/auth/mock_auth_status_consumer.h" #include "chromeos/login/auth/mock_url_fetchers.h" @@ -141,11 +141,9 @@ class CryptohomeAuthenticatorTest : public testing::Test { mock_caller_ = new cryptohome::MockAsyncMethodCaller; cryptohome::AsyncMethodCaller::InitializeForTesting(mock_caller_); - FakeDBusThreadManager* fake_dbus_thread_manager = new FakeDBusThreadManager; fake_cryptohome_client_ = new FakeCryptohomeClient; - fake_dbus_thread_manager->SetCryptohomeClient( + chromeos::DBusThreadManager::GetSetterForTesting()->SetCryptohomeClient( scoped_ptr<CryptohomeClient>(fake_cryptohome_client_)); - DBusThreadManager::InitializeForTesting(fake_dbus_thread_manager); SystemSaltGetter::Initialize(); diff --git a/chrome/browser/chromeos/login/crash_restore_browsertest.cc b/chrome/browser/chromeos/login/crash_restore_browsertest.cc index f5ce615..2f01bfe 100644 --- a/chrome/browser/chromeos/login/crash_restore_browsertest.cc +++ b/chrome/browser/chromeos/login/crash_restore_browsertest.cc @@ -12,7 +12,7 @@ #include "chrome/test/base/in_process_browser_test.h" #include "chromeos/chromeos_switches.h" #include "chromeos/dbus/cryptohome_client.h" -#include "chromeos/dbus/fake_dbus_thread_manager.h" +#include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/dbus/fake_session_manager_client.h" #include "chromeos/dbus/session_manager_client.h" #include "components/user_manager/user.h" @@ -46,12 +46,9 @@ class CrashRestoreSimpleTest : public InProcessBrowserTest { virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { // Redirect session_manager DBus calls to FakeSessionManagerClient. - FakeDBusThreadManager* dbus_thread_manager = new FakeDBusThreadManager; - dbus_thread_manager->SetFakeClients(); session_manager_client_ = new FakeSessionManagerClient; - dbus_thread_manager->SetSessionManagerClient( + chromeos::DBusThreadManager::GetSetterForTesting()->SetSessionManagerClient( scoped_ptr<SessionManagerClient>(session_manager_client_)); - DBusThreadManager::SetInstanceForTesting(dbus_thread_manager); session_manager_client_->StartSession(kUserId1); } diff --git a/chrome/browser/chromeos/login/lock/screen_locker_browsertest.cc b/chrome/browser/chromeos/login/lock/screen_locker_browsertest.cc index 49c62e8..89d3abe 100644 --- a/chrome/browser/chromeos/login/lock/screen_locker_browsertest.cc +++ b/chrome/browser/chromeos/login/lock/screen_locker_browsertest.cc @@ -19,7 +19,7 @@ #include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/ui_test_utils.h" #include "chromeos/chromeos_switches.h" -#include "chromeos/dbus/fake_dbus_thread_manager.h" +#include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/dbus/fake_session_manager_client.h" #include "chromeos/login/auth/key.h" #include "chromeos/login/auth/mock_authenticator.h" @@ -120,12 +120,9 @@ class ScreenLockerTest : public InProcessBrowserTest { private: virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { - FakeDBusThreadManager* fake_dbus_thread_manager = new FakeDBusThreadManager; - fake_dbus_thread_manager->SetFakeClients(); fake_session_manager_client_ = new FakeSessionManagerClient; - fake_dbus_thread_manager->SetSessionManagerClient( + DBusThreadManager::GetSetterForTesting()->SetSessionManagerClient( scoped_ptr<SessionManagerClient>(fake_session_manager_client_)); - DBusThreadManager::SetInstanceForTesting(fake_dbus_thread_manager); InProcessBrowserTest::SetUpInProcessBrowserTestFixture(); zero_duration_mode_.reset(new ui::ScopedAnimationDurationScaleMode( diff --git a/chrome/browser/chromeos/login/reset_browsertest.cc b/chrome/browser/chromeos/login/reset_browsertest.cc index 89eb85a..4c9ecb1 100644 --- a/chrome/browser/chromeos/login/reset_browsertest.cc +++ b/chrome/browser/chromeos/login/reset_browsertest.cc @@ -16,7 +16,6 @@ #include "chrome/common/pref_names.h" #include "chromeos/chromeos_switches.h" #include "chromeos/dbus/dbus_thread_manager.h" -#include "chromeos/dbus/fake_dbus_thread_manager.h" #include "chromeos/dbus/fake_power_manager_client.h" #include "chromeos/dbus/fake_session_manager_client.h" #include "chromeos/dbus/fake_update_engine_client.h" @@ -46,18 +45,17 @@ class ResetTest : public LoginManagerTest { // LoginManagerTest overrides: virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { - FakeDBusThreadManager* dbus_manager = new FakeDBusThreadManager; - dbus_manager->SetFakeClients(); + scoped_ptr<DBusThreadManagerSetter> dbus_setter = + chromeos::DBusThreadManager::GetSetterForTesting(); session_manager_client_ = new FakeSessionManagerClient; - dbus_manager->SetSessionManagerClient( + dbus_setter->SetSessionManagerClient( scoped_ptr<SessionManagerClient>(session_manager_client_)); power_manager_client_ = new FakePowerManagerClient; - dbus_manager->SetPowerManagerClient( + dbus_setter->SetPowerManagerClient( scoped_ptr<PowerManagerClient>(power_manager_client_)); update_engine_client_ = new FakeUpdateEngineClient; - dbus_manager->SetUpdateEngineClient( + dbus_setter->SetUpdateEngineClient( scoped_ptr<UpdateEngineClient>(update_engine_client_)); - DBusThreadManager::SetInstanceForTesting(dbus_manager); LoginManagerTest::SetUpInProcessBrowserTestFixture(); } diff --git a/chrome/browser/chromeos/login/saml/saml_browsertest.cc b/chrome/browser/chromeos/login/saml/saml_browsertest.cc index 9980037..bfc0a5b 100644 --- a/chrome/browser/chromeos/login/saml/saml_browsertest.cc +++ b/chrome/browser/chromeos/login/saml/saml_browsertest.cc @@ -39,7 +39,6 @@ #include "chrome/test/base/in_process_browser_test.h" #include "chromeos/chromeos_switches.h" #include "chromeos/dbus/dbus_thread_manager.h" -#include "chromeos/dbus/fake_dbus_thread_manager.h" #include "chromeos/dbus/fake_session_manager_client.h" #include "chromeos/dbus/session_manager_client.h" #include "chromeos/settings/cros_settings_names.h" @@ -692,7 +691,6 @@ class SAMLPolicyTest : public SamlTest { policy::DevicePolicyCrosTestHelper test_helper_; // FakeDBusThreadManager uses FakeSessionManagerClient. - FakeDBusThreadManager* fake_dbus_thread_manager_; FakeSessionManagerClient* fake_session_manager_client_; policy::DevicePolicyBuilder* device_policy_; @@ -705,19 +703,17 @@ class SAMLPolicyTest : public SamlTest { }; SAMLPolicyTest::SAMLPolicyTest() - : fake_dbus_thread_manager_(new FakeDBusThreadManager), - fake_session_manager_client_(new FakeSessionManagerClient), + : fake_session_manager_client_(new FakeSessionManagerClient), device_policy_(test_helper_.device_policy()) { - fake_dbus_thread_manager_->SetFakeClients(); - fake_dbus_thread_manager_->SetSessionManagerClient( - scoped_ptr<SessionManagerClient>(fake_session_manager_client_)); } SAMLPolicyTest::~SAMLPolicyTest() { } void SAMLPolicyTest::SetUpInProcessBrowserTestFixture() { - DBusThreadManager::SetInstanceForTesting(fake_dbus_thread_manager_); + DBusThreadManager::GetSetterForTesting()->SetSessionManagerClient( + scoped_ptr<SessionManagerClient>(fake_session_manager_client_)); + SamlTest::SetUpInProcessBrowserTestFixture(); // Initialize device policy. diff --git a/chrome/browser/chromeos/login/screens/network_screen_browsertest.cc b/chrome/browser/chromeos/login/screens/network_screen_browsertest.cc index 93640cb..5000710 100644 --- a/chrome/browser/chromeos/login/screens/network_screen_browsertest.cc +++ b/chrome/browser/chromeos/login/screens/network_screen_browsertest.cc @@ -10,7 +10,7 @@ #include "chrome/browser/chromeos/login/test/wizard_in_process_browser_test.h" #include "chrome/browser/chromeos/login/wizard_controller.h" #include "chrome/test/base/ui_test_utils.h" -#include "chromeos/dbus/fake_dbus_thread_manager.h" +#include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/dbus/fake_session_manager_client.h" #include "content/public/test/test_utils.h" #include "testing/gmock/include/gmock/gmock.h" @@ -53,12 +53,9 @@ class NetworkScreenTest : public WizardInProcessBrowserTest { virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { WizardInProcessBrowserTest::SetUpInProcessBrowserTestFixture(); - FakeDBusThreadManager* fake_dbus_thread_manager = new FakeDBusThreadManager; - fake_dbus_thread_manager->SetFakeClients(); fake_session_manager_client_ = new FakeSessionManagerClient; - fake_dbus_thread_manager->SetSessionManagerClient( + DBusThreadManager::GetSetterForTesting()->SetSessionManagerClient( scoped_ptr<SessionManagerClient>(fake_session_manager_client_)); - DBusThreadManager::SetInstanceForTesting(fake_dbus_thread_manager); } virtual void SetUpOnMainThread() OVERRIDE { diff --git a/chrome/browser/chromeos/login/screens/update_screen_browsertest.cc b/chrome/browser/chromeos/login/screens/update_screen_browsertest.cc index c0fb323..c26d1cc 100644 --- a/chrome/browser/chromeos/login/screens/update_screen_browsertest.cc +++ b/chrome/browser/chromeos/login/screens/update_screen_browsertest.cc @@ -15,7 +15,7 @@ #include "chrome/browser/chromeos/net/network_portal_detector_test_impl.h" #include "chrome/common/pref_names.h" #include "chromeos/chromeos_switches.h" -#include "chromeos/dbus/fake_dbus_thread_manager.h" +#include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/dbus/fake_update_engine_client.h" #include "chromeos/network/portal_detector/network_portal_detector.h" #include "testing/gmock/include/gmock/gmock.h" @@ -46,14 +46,10 @@ class UpdateScreenTest : public WizardInProcessBrowserTest { protected: virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { - FakeDBusThreadManager* fake_dbus_thread_manager = - new FakeDBusThreadManager; - fake_dbus_thread_manager->SetFakeClients(); fake_update_engine_client_ = new FakeUpdateEngineClient; - fake_dbus_thread_manager->SetUpdateEngineClient( + chromeos::DBusThreadManager::GetSetterForTesting()->SetUpdateEngineClient( scoped_ptr<UpdateEngineClient>(fake_update_engine_client_)); - DBusThreadManager::SetInstanceForTesting(fake_dbus_thread_manager); WizardInProcessBrowserTest::SetUpInProcessBrowserTestFixture(); // Setup network portal detector to return online state for both diff --git a/chrome/browser/chromeos/login/users/avatar/user_image_manager_browsertest.cc b/chrome/browser/chromeos/login/users/avatar/user_image_manager_browsertest.cc index ea96f5f..ced2f99 100644 --- a/chrome/browser/chromeos/login/users/avatar/user_image_manager_browsertest.cc +++ b/chrome/browser/chromeos/login/users/avatar/user_image_manager_browsertest.cc @@ -45,7 +45,6 @@ #include "chromeos/chromeos_paths.h" #include "chromeos/dbus/cryptohome_client.h" #include "chromeos/dbus/dbus_thread_manager.h" -#include "chromeos/dbus/fake_dbus_thread_manager.h" #include "chromeos/dbus/fake_session_manager_client.h" #include "chromeos/dbus/session_manager_client.h" #include "components/policy/core/common/cloud/cloud_policy_core.h" @@ -601,16 +600,13 @@ class UserImageManagerPolicyTest : public UserImageManagerTest, public policy::CloudPolicyStore::Observer { protected: UserImageManagerPolicyTest() - : fake_dbus_thread_manager_(new chromeos::FakeDBusThreadManager), - fake_session_manager_client_(new chromeos::FakeSessionManagerClient) { - fake_dbus_thread_manager_->SetFakeClients(); - fake_dbus_thread_manager_->SetSessionManagerClient( - scoped_ptr<SessionManagerClient>(fake_session_manager_client_)); + : fake_session_manager_client_(new chromeos::FakeSessionManagerClient) { } // UserImageManagerTest overrides: virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { - DBusThreadManager::SetInstanceForTesting(fake_dbus_thread_manager_); + DBusThreadManager::GetSetterForTesting()->SetSessionManagerClient( + scoped_ptr<SessionManagerClient>(fake_session_manager_client_)); UserImageManagerTest::SetUpInProcessBrowserTestFixture(); } @@ -668,7 +664,6 @@ class UserImageManagerPolicyTest : public UserImageManagerTest, } policy::UserPolicyBuilder user_policy_; - FakeDBusThreadManager* fake_dbus_thread_manager_; FakeSessionManagerClient* fake_session_manager_client_; scoped_ptr<gfx::ImageSkia> policy_image_; diff --git a/chrome/browser/chromeos/login/users/user_manager_unittest.cc b/chrome/browser/chromeos/login/users/user_manager_unittest.cc index 5a3e989..7c448a4 100644 --- a/chrome/browser/chromeos/login/users/user_manager_unittest.cc +++ b/chrome/browser/chromeos/login/users/user_manager_unittest.cc @@ -23,7 +23,6 @@ #include "chrome/test/base/testing_profile.h" #include "chromeos/chromeos_switches.h" #include "chromeos/dbus/dbus_thread_manager.h" -#include "chromeos/dbus/fake_dbus_thread_manager.h" #include "chromeos/settings/cros_settings_names.h" #include "chromeos/settings/cros_settings_provider.h" #include "components/user_manager/user.h" @@ -80,9 +79,7 @@ class UserManagerTest : public testing::Test { TestingBrowserProcess::GetGlobal()->SetProfileManager( new UnittestProfileManager(temp_dir_.path())); - chromeos::FakeDBusThreadManager* dbus_manager = - new chromeos::FakeDBusThreadManager(); - chromeos::DBusThreadManager::InitializeForTesting(dbus_manager); + chromeos::DBusThreadManager::Initialize(); ResetUserManager(); } diff --git a/chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager_policy_browsertest.cc b/chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager_policy_browsertest.cc index e24bc86..0e89f4b 100644 --- a/chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager_policy_browsertest.cc +++ b/chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager_policy_browsertest.cc @@ -31,7 +31,6 @@ #include "chromeos/chromeos_switches.h" #include "chromeos/dbus/cryptohome_client.h" #include "chromeos/dbus/dbus_thread_manager.h" -#include "chromeos/dbus/fake_dbus_thread_manager.h" #include "chromeos/dbus/fake_session_manager_client.h" #include "chromeos/dbus/session_manager_client.h" #include "components/policy/core/common/cloud/cloud_policy_core.h" @@ -136,11 +135,7 @@ class WallpaperManagerPolicyTest WallpaperManagerPolicyTest() : LoginManagerTest(true), wallpaper_change_count_(0), - fake_dbus_thread_manager_(new FakeDBusThreadManager), fake_session_manager_client_(new FakeSessionManagerClient) { - fake_dbus_thread_manager_->SetFakeClients(); - fake_dbus_thread_manager_->SetSessionManagerClient( - scoped_ptr<SessionManagerClient>(fake_session_manager_client_)); } scoped_ptr<policy::UserPolicyBuilder> GetUserPolicyBuilder( @@ -169,7 +164,9 @@ class WallpaperManagerPolicyTest // LoginManagerTest: virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { - DBusThreadManager::SetInstanceForTesting(fake_dbus_thread_manager_); + DBusThreadManager::GetSetterForTesting()->SetSessionManagerClient( + scoped_ptr<SessionManagerClient>(fake_session_manager_client_)); + LoginManagerTest::SetUpInProcessBrowserTestFixture(); ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir_)); } @@ -266,7 +263,6 @@ class WallpaperManagerPolicyTest scoped_ptr<base::RunLoop> run_loop_; int wallpaper_change_count_; scoped_ptr<policy::UserPolicyBuilder> user_policy_builders_[2]; - FakeDBusThreadManager* fake_dbus_thread_manager_; FakeSessionManagerClient* fake_session_manager_client_; private: diff --git a/chrome/browser/chromeos/login/wizard_controller_browsertest.cc b/chrome/browser/chromeos/login/wizard_controller_browsertest.cc index 2e26521..a461e88 100644 --- a/chrome/browser/chromeos/login/wizard_controller_browsertest.cc +++ b/chrome/browser/chromeos/login/wizard_controller_browsertest.cc @@ -53,7 +53,6 @@ #include "chromeos/chromeos_switches.h" #include "chromeos/chromeos_test_utils.h" #include "chromeos/dbus/dbus_thread_manager.h" -#include "chromeos/dbus/fake_dbus_thread_manager.h" #include "chromeos/dbus/fake_session_manager_client.h" #include "chromeos/login/auth/key.h" #include "chromeos/login/auth/mock_auth_status_consumer.h" @@ -799,13 +798,9 @@ class WizardControllerBrokenLocalStateTest : public WizardControllerTest { virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { WizardControllerTest::SetUpInProcessBrowserTestFixture(); - FakeDBusThreadManager* fake_dbus_thread_manager = - new FakeDBusThreadManager(); - fake_dbus_thread_manager->SetFakeClients(); fake_session_manager_client_ = new FakeSessionManagerClient; - fake_dbus_thread_manager->SetSessionManagerClient( + DBusThreadManager::GetSetterForTesting()->SetSessionManagerClient( scoped_ptr<SessionManagerClient>(fake_session_manager_client_)); - DBusThreadManager::SetInstanceForTesting(fake_dbus_thread_manager); } virtual void SetUpOnMainThread() OVERRIDE { diff --git a/chrome/browser/chromeos/mobile/mobile_activator_unittest.cc b/chrome/browser/chromeos/mobile/mobile_activator_unittest.cc index b0e5b381..9cdd323 100644 --- a/chrome/browser/chromeos/mobile/mobile_activator_unittest.cc +++ b/chrome/browser/chromeos/mobile/mobile_activator_unittest.cc @@ -114,7 +114,7 @@ class MobileActivatorTest : public testing::Test { protected: virtual void SetUp() { - DBusThreadManager::InitializeWithStub(); + DBusThreadManager::Initialize(); NetworkHandler::Initialize(); } virtual void TearDown() { diff --git a/chrome/browser/chromeos/net/network_portal_detector_impl_unittest.cc b/chrome/browser/chromeos/net/network_portal_detector_impl_unittest.cc index 6835bb4..f692f13 100644 --- a/chrome/browser/chromeos/net/network_portal_detector_impl_unittest.cc +++ b/chrome/browser/chromeos/net/network_portal_detector_impl_unittest.cc @@ -70,7 +70,7 @@ class NetworkPortalDetectorImplTest CommandLine* cl = CommandLine::ForCurrentProcess(); cl->AppendSwitch(switches::kDisableNetworkPortalNotification); - DBusThreadManager::InitializeWithStub(); + DBusThreadManager::Initialize(); base::StatisticsRecorder::Initialize(); SetupNetworkHandler(); diff --git a/chrome/browser/chromeos/policy/device_cloud_policy_invalidator_unittest.cc b/chrome/browser/chromeos/policy/device_cloud_policy_invalidator_unittest.cc index cd3363b..5af385a 100644 --- a/chrome/browser/chromeos/policy/device_cloud_policy_invalidator_unittest.cc +++ b/chrome/browser/chromeos/policy/device_cloud_policy_invalidator_unittest.cc @@ -120,7 +120,7 @@ DeviceCloudPolicyInvalidatorTest::~DeviceCloudPolicyInvalidatorTest() { void DeviceCloudPolicyInvalidatorTest::SetUp() { chromeos::SystemSaltGetter::Initialize(); - chromeos::DBusThreadManager::InitializeWithStub(); + chromeos::DBusThreadManager::Initialize(); chromeos::DeviceOAuth2TokenServiceFactory::Initialize(); TestingBrowserProcess::GetGlobal()->SetSystemRequestContext( system_request_context_.get()); diff --git a/chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos_unittest.cc b/chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos_unittest.cc index 5386ba46..09d8da2 100644 --- a/chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos_unittest.cc +++ b/chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos_unittest.cc @@ -30,7 +30,6 @@ #include "chromeos/dbus/dbus_client_implementation_type.h" #include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/dbus/fake_cryptohome_client.h" -#include "chromeos/dbus/fake_dbus_thread_manager.h" #include "chromeos/dbus/fake_session_manager_client.h" #include "chromeos/system/mock_statistics_provider.h" #include "chromeos/system/statistics_provider.h" @@ -89,8 +88,6 @@ class DeviceCloudPolicyManagerChromeOSTest state_keys.push_back("2"); state_keys.push_back("3"); fake_session_manager_client_.set_server_backed_state_keys(state_keys); - fake_dbus_thread_manager_->SetCryptohomeClient( - scoped_ptr<chromeos::CryptohomeClient>(fake_cryptohome_client_)); } virtual ~DeviceCloudPolicyManagerChromeOSTest() { @@ -99,6 +96,8 @@ class DeviceCloudPolicyManagerChromeOSTest virtual void SetUp() OVERRIDE { DeviceSettingsTestBase::SetUp(); + dbus_setter_->SetCryptohomeClient( + scoped_ptr<chromeos::CryptohomeClient>(fake_cryptohome_client_)); install_attributes_.reset( new EnterpriseInstallAttributes(fake_cryptohome_client_)); diff --git a/chrome/browser/chromeos/policy/device_cloud_policy_store_chromeos_unittest.cc b/chrome/browser/chromeos/policy/device_cloud_policy_store_chromeos_unittest.cc index f386070..ebf92d6 100644 --- a/chrome/browser/chromeos/policy/device_cloud_policy_store_chromeos_unittest.cc +++ b/chrome/browser/chromeos/policy/device_cloud_policy_store_chromeos_unittest.cc @@ -17,8 +17,8 @@ #include "chrome/test/base/scoped_testing_local_state.h" #include "chrome/test/base/testing_browser_process.h" #include "chromeos/cryptohome/cryptohome_util.h" +#include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/dbus/fake_cryptohome_client.h" -#include "chromeos/dbus/fake_dbus_thread_manager.h" #include "policy/policy_constants.h" #include "testing/gtest/include/gtest/gtest.h" @@ -47,13 +47,14 @@ class DeviceCloudPolicyStoreChromeOSTest &device_settings_service_, install_attributes_.get(), base::MessageLoopProxy::current())) { - fake_dbus_thread_manager_->SetCryptohomeClient( - scoped_ptr<chromeos::CryptohomeClient>(fake_cryptohome_client_)); } virtual void SetUp() OVERRIDE { DeviceSettingsTestBase::SetUp(); + dbus_setter_->SetCryptohomeClient( + scoped_ptr<chromeos::CryptohomeClient>(fake_cryptohome_client_)); + base::RunLoop loop; EnterpriseInstallAttributes::LockResult result; install_attributes_->LockDevice( diff --git a/chrome/browser/chromeos/policy/device_policy_cros_browser_test.cc b/chrome/browser/chromeos/policy/device_policy_cros_browser_test.cc index 32c162c..59e8401 100644 --- a/chrome/browser/chromeos/policy/device_policy_cros_browser_test.cc +++ b/chrome/browser/chromeos/policy/device_policy_cros_browser_test.cc @@ -15,7 +15,7 @@ #include "chrome/browser/chromeos/policy/enterprise_install_attributes.h" #include "chrome/common/chrome_paths.h" #include "chromeos/chromeos_paths.h" -#include "chromeos/dbus/fake_dbus_thread_manager.h" +#include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/dbus/fake_session_manager_client.h" #include "crypto/rsa_private_key.h" #include "testing/gmock/include/gmock/gmock.h" @@ -73,18 +73,16 @@ void DevicePolicyCrosTestHelper::OverridePaths() { } DevicePolicyCrosBrowserTest::DevicePolicyCrosBrowserTest() - : fake_dbus_thread_manager_(new chromeos::FakeDBusThreadManager), - fake_session_manager_client_(new chromeos::FakeSessionManagerClient) { - fake_dbus_thread_manager_->SetFakeClients(); - fake_dbus_thread_manager_->SetSessionManagerClient( - scoped_ptr<chromeos::SessionManagerClient>(fake_session_manager_client_)); + : fake_session_manager_client_(new chromeos::FakeSessionManagerClient) { } DevicePolicyCrosBrowserTest::~DevicePolicyCrosBrowserTest() { } void DevicePolicyCrosBrowserTest::SetUpInProcessBrowserTestFixture() { - chromeos::DBusThreadManager::SetInstanceForTesting(fake_dbus_thread_manager_); + dbus_setter_ = chromeos::DBusThreadManager::GetSetterForTesting(); + dbus_setter_->SetSessionManagerClient( + scoped_ptr<chromeos::SessionManagerClient>(fake_session_manager_client_)); InProcessBrowserTest::SetUpInProcessBrowserTestFixture(); } diff --git a/chrome/browser/chromeos/policy/device_policy_cros_browser_test.h b/chrome/browser/chromeos/policy/device_policy_cros_browser_test.h index 1547504..9ec7f82 100644 --- a/chrome/browser/chromeos/policy/device_policy_cros_browser_test.h +++ b/chrome/browser/chromeos/policy/device_policy_cros_browser_test.h @@ -9,7 +9,7 @@ #include "base/compiler_specific.h" #include "chrome/browser/chromeos/policy/device_policy_builder.h" #include "chrome/test/base/in_process_browser_test.h" -#include "chromeos/dbus/fake_dbus_thread_manager.h" +#include "chromeos/dbus/dbus_thread_manager.h" namespace chromeos { class FakeSessionManagerClient; @@ -62,8 +62,8 @@ class DevicePolicyCrosBrowserTest : public InProcessBrowserTest { // recently changed). void RefreshDevicePolicy(); - chromeos::FakeDBusThreadManager* fake_dbus_thread_manager() { - return fake_dbus_thread_manager_; + chromeos::DBusThreadManagerSetter* dbus_setter() { + return dbus_setter_.get(); } chromeos::FakeSessionManagerClient* session_manager_client() { @@ -76,7 +76,7 @@ class DevicePolicyCrosBrowserTest : public InProcessBrowserTest { DevicePolicyCrosTestHelper test_helper_; // FakeDBusThreadManager uses FakeSessionManagerClient. - chromeos::FakeDBusThreadManager* fake_dbus_thread_manager_; + scoped_ptr<chromeos::DBusThreadManagerSetter> dbus_setter_; chromeos::FakeSessionManagerClient* fake_session_manager_client_; DISALLOW_COPY_AND_ASSIGN(DevicePolicyCrosBrowserTest); diff --git a/chrome/browser/chromeos/policy/device_status_collector_browsertest.cc b/chrome/browser/chromeos/policy/device_status_collector_browsertest.cc index 215f6ec..9e1137d 100644 --- a/chrome/browser/chromeos/policy/device_status_collector_browsertest.cc +++ b/chrome/browser/chromeos/policy/device_status_collector_browsertest.cc @@ -709,7 +709,7 @@ class DeviceStatusCollectorNetworkInterfacesTest : public DeviceStatusCollectorTest { protected: virtual void SetUp() OVERRIDE { - chromeos::DBusThreadManager::InitializeWithStub(); + chromeos::DBusThreadManager::Initialize(); chromeos::NetworkHandler::Initialize(); chromeos::ShillDeviceClient::TestInterface* test_device_client = chromeos::DBusThreadManager::Get()->GetShillDeviceClient()-> diff --git a/chrome/browser/chromeos/policy/enterprise_install_attributes_unittest.cc b/chrome/browser/chromeos/policy/enterprise_install_attributes_unittest.cc index 455ae1e..9b66adb 100644 --- a/chrome/browser/chromeos/policy/enterprise_install_attributes_unittest.cc +++ b/chrome/browser/chromeos/policy/enterprise_install_attributes_unittest.cc @@ -47,7 +47,7 @@ class EnterpriseInstallAttributesTest : public testing::Test { ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); ASSERT_TRUE(PathService::OverrideAndCreateIfNeeded( chromeos::FILE_INSTALL_ATTRIBUTES, GetTempPath(), true, false)); - chromeos::DBusThreadManager::InitializeWithStub(); + chromeos::DBusThreadManager::Initialize(); install_attributes_.reset(new EnterpriseInstallAttributes( chromeos::DBusThreadManager::Get()->GetCryptohomeClient())); } diff --git a/chrome/browser/chromeos/policy/power_policy_browsertest.cc b/chrome/browser/chromeos/policy/power_policy_browsertest.cc index 90288cd..feacbd1 100644 --- a/chrome/browser/chromeos/policy/power_policy_browsertest.cc +++ b/chrome/browser/chromeos/policy/power_policy_browsertest.cc @@ -33,7 +33,7 @@ #include "chromeos/chromeos_paths.h" #include "chromeos/chromeos_switches.h" #include "chromeos/dbus/cryptohome_client.h" -#include "chromeos/dbus/fake_dbus_thread_manager.h" +#include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/dbus/fake_power_manager_client.h" #include "chromeos/dbus/fake_session_manager_client.h" #include "chromeos/dbus/power_manager/policy.pb.h" @@ -177,12 +177,11 @@ PowerPolicyBrowserTestBase::PowerPolicyBrowserTestBase() } void PowerPolicyBrowserTestBase::SetUpInProcessBrowserTestFixture() { + DevicePolicyCrosBrowserTest::SetUpInProcessBrowserTestFixture(); power_manager_client_ = new chromeos::FakePowerManagerClient; - fake_dbus_thread_manager()->SetPowerManagerClient( + dbus_setter()->SetPowerManagerClient( scoped_ptr<chromeos::PowerManagerClient>(power_manager_client_)); - DevicePolicyCrosBrowserTest::SetUpInProcessBrowserTestFixture(); - // Initialize device policy. InstallOwnerKey(); MarkAsEnterpriseOwned(); diff --git a/chrome/browser/chromeos/power/peripheral_battery_observer_browsertest.cc b/chrome/browser/chromeos/power/peripheral_battery_observer_browsertest.cc index 27c7218..8d93dbf 100644 --- a/chrome/browser/chromeos/power/peripheral_battery_observer_browsertest.cc +++ b/chrome/browser/chromeos/power/peripheral_battery_observer_browsertest.cc @@ -9,7 +9,7 @@ #include "chrome/browser/browser_process.h" #include "chrome/browser/notifications/notification_ui_manager.h" #include "chrome/test/base/in_process_browser_test.h" -#include "chromeos/dbus/fake_dbus_thread_manager.h" +#include "chromeos/dbus/dbus_thread_manager.h" #include "content/public/test/test_utils.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" @@ -34,11 +34,11 @@ class PeripheralBatteryObserverTest : public InProcessBrowserTest { PeripheralBatteryObserverTest() {} virtual ~PeripheralBatteryObserverTest() {} + virtual void SetUp() OVERRIDE { + chromeos::DBusThreadManager::Initialize(); + } + virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { - FakeDBusThreadManager* fake_dbus_thread_manager = - new FakeDBusThreadManager; - fake_dbus_thread_manager->SetFakeClients(); - DBusThreadManager::SetInstanceForTesting(fake_dbus_thread_manager); InProcessBrowserTest::SetUpInProcessBrowserTestFixture(); } diff --git a/chrome/browser/chromeos/power/power_data_collector_unittest.cc b/chrome/browser/chromeos/power/power_data_collector_unittest.cc index 821d1d4..db2df82 100644 --- a/chrome/browser/chromeos/power/power_data_collector_unittest.cc +++ b/chrome/browser/chromeos/power/power_data_collector_unittest.cc @@ -4,7 +4,6 @@ #include "chrome/browser/chromeos/power/power_data_collector.h" #include "chromeos/dbus/dbus_thread_manager.h" -#include "chromeos/dbus/fake_dbus_thread_manager.h" #include "chromeos/dbus/power_manager/power_supply_properties.pb.h" #include "testing/gtest/include/gtest/gtest.h" @@ -16,9 +15,7 @@ class PowerDataCollectorTest : public testing::Test { virtual ~PowerDataCollectorTest() {} virtual void SetUp() OVERRIDE { - FakeDBusThreadManager* fake_dbus_thread_manager = new FakeDBusThreadManager; - fake_dbus_thread_manager->SetFakeClients(); - DBusThreadManager::InitializeForTesting(fake_dbus_thread_manager); + DBusThreadManager::Initialize(); PowerDataCollector::InitializeForTesting(); power_data_collector_ = PowerDataCollector::Get(); } diff --git a/chrome/browser/chromeos/power/power_prefs_unittest.cc b/chrome/browser/chromeos/power/power_prefs_unittest.cc index 59f40cd..061dfbf 100644 --- a/chrome/browser/chromeos/power/power_prefs_unittest.cc +++ b/chrome/browser/chromeos/power/power_prefs_unittest.cc @@ -26,7 +26,7 @@ #include "chrome/test/base/testing_profile.h" #include "chrome/test/base/testing_profile_manager.h" #include "chromeos/chromeos_switches.h" -#include "chromeos/dbus/fake_dbus_thread_manager.h" +#include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/dbus/fake_power_manager_client.h" #include "chromeos/dbus/power_manager/policy.pb.h" #include "chromeos/dbus/power_policy_controller.h" @@ -54,7 +54,6 @@ class PowerPrefsTest : public testing::Test { bool GetCurrentAllowScreenWakeLocks() const; TestingProfileManager profile_manager_; - FakeDBusThreadManager fake_dbus_thread_manager_; PowerPolicyController* power_policy_controller_; // Not owned. FakePowerManagerClient* fake_power_manager_client_; // Not owned. @@ -65,17 +64,21 @@ class PowerPrefsTest : public testing::Test { PowerPrefsTest::PowerPrefsTest() : profile_manager_(TestingBrowserProcess::GetGlobal()), - power_policy_controller_(new PowerPolicyController), + power_policy_controller_(NULL), fake_power_manager_client_(new FakePowerManagerClient) { - fake_dbus_thread_manager_.SetPowerManagerClient( - scoped_ptr<PowerManagerClient>(fake_power_manager_client_)); - fake_dbus_thread_manager_.SetPowerPolicyController( - scoped_ptr<PowerPolicyController>(power_policy_controller_)); - power_policy_controller_->Init(&fake_dbus_thread_manager_); } void PowerPrefsTest::SetUp() { testing::Test::SetUp(); + + scoped_ptr<DBusThreadManagerSetter> dbus_setter = + chromeos::DBusThreadManager::GetSetterForTesting(); + dbus_setter->SetPowerManagerClient( + scoped_ptr<PowerManagerClient>(fake_power_manager_client_)); + // Power policy controller is recreated with SetPowerManagerClient(). + power_policy_controller_ = + chromeos::DBusThreadManager::Get()->GetPowerPolicyController(); + ASSERT_TRUE(profile_manager_.SetUp()); power_prefs_.reset(new PowerPrefs(power_policy_controller_)); diff --git a/chrome/browser/chromeos/proxy_config_service_impl_unittest.cc b/chrome/browser/chromeos/proxy_config_service_impl_unittest.cc index 478e1fe..88e025b 100644 --- a/chrome/browser/chromeos/proxy_config_service_impl_unittest.cc +++ b/chrome/browser/chromeos/proxy_config_service_impl_unittest.cc @@ -215,7 +215,7 @@ class ProxyConfigServiceImplTest : public testing::Test { io_thread_(BrowserThread::IO, &loop_) {} virtual void SetUp() { - DBusThreadManager::InitializeWithStub(); + DBusThreadManager::Initialize(); NetworkHandler::Initialize(); SetUpNetwork(); diff --git a/chrome/browser/chromeos/settings/device_oauth2_token_service_unittest.cc b/chrome/browser/chromeos/settings/device_oauth2_token_service_unittest.cc index 303b177..c9f0814 100644 --- a/chrome/browser/chromeos/settings/device_oauth2_token_service_unittest.cc +++ b/chrome/browser/chromeos/settings/device_oauth2_token_service_unittest.cc @@ -16,8 +16,8 @@ #include "chrome/test/base/scoped_testing_local_state.h" #include "chrome/test/base/testing_browser_process.h" #include "chromeos/cryptohome/system_salt_getter.h" +#include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/dbus/fake_cryptohome_client.h" -#include "chromeos/dbus/fake_dbus_thread_manager.h" #include "content/public/browser/browser_thread.h" #include "content/public/test/test_browser_thread.h" #include "google_apis/gaia/gaia_oauth_client.h" @@ -73,17 +73,13 @@ class DeviceOAuth2TokenServiceTest : public testing::Test { } virtual void SetUp() OVERRIDE { - scoped_ptr<FakeDBusThreadManager> fake_dbus_thread_manager( - new FakeDBusThreadManager); fake_cryptohome_client_ = new FakeCryptohomeClient; fake_cryptohome_client_->SetServiceIsAvailable(true); fake_cryptohome_client_->set_system_salt( FakeCryptohomeClient::GetStubSystemSalt()); - fake_dbus_thread_manager->SetCryptohomeClient( + chromeos::DBusThreadManager::GetSetterForTesting()->SetCryptohomeClient( scoped_ptr<CryptohomeClient>(fake_cryptohome_client_)); - DBusThreadManager::InitializeForTesting(fake_dbus_thread_manager.release()); - SystemSaltGetter::Initialize(); DeviceSettingsService::Initialize(); diff --git a/chrome/browser/chromeos/settings/device_settings_test_helper.cc b/chrome/browser/chromeos/settings/device_settings_test_helper.cc index e9e9df6..ae21509 100644 --- a/chrome/browser/chromeos/settings/device_settings_test_helper.cc +++ b/chrome/browser/chromeos/settings/device_settings_test_helper.cc @@ -16,7 +16,6 @@ #include "chrome/test/base/testing_browser_process.h" #include "chrome/test/base/testing_profile.h" #include "chromeos/dbus/dbus_thread_manager.h" -#include "chromeos/dbus/fake_dbus_thread_manager.h" #include "content/public/browser/browser_thread.h" namespace chromeos { @@ -206,8 +205,7 @@ ScopedDeviceSettingsTestHelper::~ScopedDeviceSettingsTestHelper() { DeviceSettingsTestBase::DeviceSettingsTestBase() : user_manager_(new FakeUserManager()), user_manager_enabler_(user_manager_), - owner_key_util_(new MockOwnerKeyUtil()), - fake_dbus_thread_manager_(new FakeDBusThreadManager()) { + owner_key_util_(new MockOwnerKeyUtil()) { } DeviceSettingsTestBase::~DeviceSettingsTestBase() { @@ -216,7 +214,7 @@ DeviceSettingsTestBase::~DeviceSettingsTestBase() { void DeviceSettingsTestBase::SetUp() { // Initialize DBusThreadManager with a stub implementation. - chromeos::DBusThreadManager::InitializeForTesting(fake_dbus_thread_manager_); + dbus_setter_ = chromeos::DBusThreadManager::GetSetterForTesting(); base::RunLoop().RunUntilIdle(); diff --git a/chrome/browser/chromeos/settings/device_settings_test_helper.h b/chrome/browser/chromeos/settings/device_settings_test_helper.h index fc66da9..a01fb9f 100644 --- a/chrome/browser/chromeos/settings/device_settings_test_helper.h +++ b/chrome/browser/chromeos/settings/device_settings_test_helper.h @@ -29,7 +29,7 @@ class TestingProfile; namespace chromeos { -class FakeDBusThreadManager; +class DBusThreadManagerSetter; // A helper class for tests mocking out session_manager's device settings // interface. The pattern is to initialize DeviceSettingsService with the helper @@ -194,7 +194,7 @@ class DeviceSettingsTestBase : public testing::Test { // with the global instance (DeviceSettingsService::Get()). DeviceSettingsService device_settings_service_; - chromeos::FakeDBusThreadManager* fake_dbus_thread_manager_; + scoped_ptr<DBusThreadManagerSetter> dbus_setter_; private: DISALLOW_COPY_AND_ASSIGN(DeviceSettingsTestBase); diff --git a/chrome/browser/chromeos/system/automatic_reboot_manager_unittest.cc b/chrome/browser/chromeos/system/automatic_reboot_manager_unittest.cc index 0c6334b..82744c5 100644 --- a/chrome/browser/chromeos/system/automatic_reboot_manager_unittest.cc +++ b/chrome/browser/chromeos/system/automatic_reboot_manager_unittest.cc @@ -33,7 +33,6 @@ #include "chrome/test/base/testing_browser_process.h" #include "chromeos/chromeos_paths.h" #include "chromeos/dbus/dbus_thread_manager.h" -#include "chromeos/dbus/fake_dbus_thread_manager.h" #include "chromeos/dbus/fake_power_manager_client.h" #include "chromeos/dbus/fake_update_engine_client.h" #include "content/public/browser/browser_thread.h" @@ -357,14 +356,14 @@ void AutomaticRebootManagerBasicTest::SetUp() { TestingBrowserProcess::GetGlobal()->SetLocalState(&local_state_); AutomaticRebootManager::RegisterPrefs(local_state_.registry()); - FakeDBusThreadManager* dbus_manager = new FakeDBusThreadManager; + scoped_ptr<DBusThreadManagerSetter> dbus_setter = + chromeos::DBusThreadManager::GetSetterForTesting(); power_manager_client_ = new FakePowerManagerClient; - dbus_manager->SetPowerManagerClient( + dbus_setter->SetPowerManagerClient( scoped_ptr<PowerManagerClient>(power_manager_client_)); update_engine_client_ = new FakeUpdateEngineClient; - dbus_manager->SetUpdateEngineClient( + dbus_setter->SetUpdateEngineClient( scoped_ptr<UpdateEngineClient>(update_engine_client_)); - DBusThreadManager::InitializeForTesting(dbus_manager); EXPECT_CALL(*mock_user_manager_, IsUserLoggedIn()) .WillRepeatedly(ReturnPointee(&is_user_logged_in_)); diff --git a/chrome/browser/extensions/api/image_writer_private/test_utils.cc b/chrome/browser/extensions/api/image_writer_private/test_utils.cc index 442b041..5cae145 100644 --- a/chrome/browser/extensions/api/image_writer_private/test_utils.cc +++ b/chrome/browser/extensions/api/image_writer_private/test_utils.cc @@ -6,7 +6,6 @@ #if defined(OS_CHROMEOS) #include "chromeos/dbus/dbus_thread_manager.h" -#include "chromeos/dbus/fake_dbus_thread_manager.h" #include "chromeos/dbus/fake_image_burner_client.h" #endif @@ -161,20 +160,11 @@ void ImageWriterTestUtils::SetUp(bool is_browser_test) { #if defined(OS_CHROMEOS) if (!chromeos::DBusThreadManager::IsInitialized()) { - chromeos::FakeDBusThreadManager* fake_dbus_thread_manager = - new chromeos::FakeDBusThreadManager; - fake_dbus_thread_manager->SetFakeClients(); + scoped_ptr<chromeos::DBusThreadManagerSetter> dbus_setter = + chromeos::DBusThreadManager::GetSetterForTesting(); scoped_ptr<chromeos::ImageBurnerClient> image_burner_fake(new ImageWriterFakeImageBurnerClient()); - fake_dbus_thread_manager->SetImageBurnerClient(image_burner_fake.Pass()); - - if (is_browser_test) { - chromeos::DBusThreadManager::SetInstanceForTesting( - fake_dbus_thread_manager); - } else { - chromeos::DBusThreadManager::InitializeForTesting( - fake_dbus_thread_manager); - } + dbus_setter->SetImageBurnerClient(image_burner_fake.Pass()); } FakeDiskMountManager* disk_manager = new FakeDiskMountManager(); diff --git a/chrome/browser/extensions/api/log_private/log_private_apitest_chromeos.cc b/chrome/browser/extensions/api/log_private/log_private_apitest_chromeos.cc index 4fb9207..316a621 100644 --- a/chrome/browser/extensions/api/log_private/log_private_apitest_chromeos.cc +++ b/chrome/browser/extensions/api/log_private/log_private_apitest_chromeos.cc @@ -8,7 +8,7 @@ #include "base/files/file_util.h" #include "chrome/browser/extensions/extension_apitest.h" #include "chrome/common/chrome_switches.h" -#include "chromeos/dbus/fake_dbus_thread_manager.h" +#include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/dbus/fake_debug_daemon_client.h" #include "content/public/browser/browser_thread.h" #include "extensions/common/extension_builder.h" @@ -68,16 +68,11 @@ class LogPrivateApiTest : public ExtensionApiTest { virtual ~LogPrivateApiTest() {} virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { - chromeos::FakeDBusThreadManager* fake_dbus_thread_manager = - new chromeos::FakeDBusThreadManager; - fake_dbus_thread_manager->SetFakeClients(); base::FilePath tar_file_path = test_data_dir_.Append("log_private/dump_logs/system_logs.tar"); - fake_dbus_thread_manager->SetDebugDaemonClient( + chromeos::DBusThreadManager::GetSetterForTesting()->SetDebugDaemonClient( scoped_ptr<chromeos::DebugDaemonClient>( new TestDebugDaemonClient(tar_file_path))); - chromeos::DBusThreadManager::SetInstanceForTesting( - fake_dbus_thread_manager); ExtensionApiTest::SetUpInProcessBrowserTestFixture(); } diff --git a/chrome/browser/extensions/api/system_private/system_private_apitest.cc b/chrome/browser/extensions/api/system_private/system_private_apitest.cc index f242095..f0f01f8c 100644 --- a/chrome/browser/extensions/api/system_private/system_private_apitest.cc +++ b/chrome/browser/extensions/api/system_private/system_private_apitest.cc @@ -9,7 +9,7 @@ #include "chrome/common/pref_names.h" #if defined(OS_CHROMEOS) -#include "chromeos/dbus/fake_dbus_thread_manager.h" +#include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/dbus/fake_update_engine_client.h" using chromeos::UpdateEngineClient; @@ -31,14 +31,9 @@ class GetUpdateStatusApiTest : public ExtensionApiTest { virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { ExtensionApiTest::SetUpInProcessBrowserTestFixture(); - chromeos::FakeDBusThreadManager* fake_dbus_thread_manager = - new chromeos::FakeDBusThreadManager; - fake_dbus_thread_manager->SetFakeClients(); fake_update_engine_client_ = new chromeos::FakeUpdateEngineClient; - fake_dbus_thread_manager->SetUpdateEngineClient( + chromeos::DBusThreadManager::GetSetterForTesting()->SetUpdateEngineClient( scoped_ptr<UpdateEngineClient>(fake_update_engine_client_)); - chromeos::DBusThreadManager::SetInstanceForTesting( - fake_dbus_thread_manager); } virtual void TearDownInProcessBrowserTestFixture() OVERRIDE { diff --git a/chrome/browser/metrics/chromeos_metrics_provider_unittest.cc b/chrome/browser/metrics/chromeos_metrics_provider_unittest.cc index a9ae53ef..fd5e3a8 100644 --- a/chrome/browser/metrics/chromeos_metrics_provider_unittest.cc +++ b/chrome/browser/metrics/chromeos_metrics_provider_unittest.cc @@ -10,6 +10,7 @@ #include "chrome/browser/chromeos/login/users/fake_user_manager.h" #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" #include "chrome/browser/metrics/chromeos_metrics_provider.h" +#include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/dbus/fake_bluetooth_adapter_client.h" #include "chromeos/dbus/fake_bluetooth_agent_manager_client.h" #include "chromeos/dbus/fake_bluetooth_device_client.h" @@ -17,7 +18,6 @@ #include "chromeos/dbus/fake_bluetooth_gatt_descriptor_client.h" #include "chromeos/dbus/fake_bluetooth_gatt_service_client.h" #include "chromeos/dbus/fake_bluetooth_input_client.h" -#include "chromeos/dbus/fake_dbus_thread_manager.h" #include "chromeos/dbus/power_manager_client.h" #include "chromeos/login/login_state.h" #include "components/metrics/proto/system_profile.pb.h" @@ -31,6 +31,7 @@ #endif using chromeos::DBusThreadManager; +using chromeos::DBusThreadManagerSetter; using chromeos::BluetoothAdapterClient; using chromeos::BluetoothAgentManagerClient; using chromeos::BluetoothDeviceClient; @@ -45,7 +46,6 @@ using chromeos::FakeBluetoothGattCharacteristicClient; using chromeos::FakeBluetoothGattDescriptorClient; using chromeos::FakeBluetoothGattServiceClient; using chromeos::FakeBluetoothInputClient; -using chromeos::FakeDBusThreadManager; using chromeos::PowerManagerClient; using chromeos::STUB_DBUS_CLIENT_IMPLEMENTATION; @@ -60,34 +60,32 @@ class ChromeOSMetricsProviderTest : public testing::Test { #endif // Set up the fake Bluetooth environment, - scoped_ptr<FakeDBusThreadManager> fake_dbus_thread_manager( - new FakeDBusThreadManager); - fake_dbus_thread_manager->SetBluetoothAdapterClient( + scoped_ptr<DBusThreadManagerSetter> dbus_setter = + DBusThreadManager::GetSetterForTesting(); + dbus_setter->SetBluetoothAdapterClient( scoped_ptr<BluetoothAdapterClient>(new FakeBluetoothAdapterClient)); - fake_dbus_thread_manager->SetBluetoothDeviceClient( + dbus_setter->SetBluetoothDeviceClient( scoped_ptr<BluetoothDeviceClient>(new FakeBluetoothDeviceClient)); - fake_dbus_thread_manager->SetBluetoothGattCharacteristicClient( + dbus_setter->SetBluetoothGattCharacteristicClient( scoped_ptr<BluetoothGattCharacteristicClient>( new FakeBluetoothGattCharacteristicClient)); - fake_dbus_thread_manager->SetBluetoothGattDescriptorClient( + dbus_setter->SetBluetoothGattDescriptorClient( scoped_ptr<BluetoothGattDescriptorClient>( new FakeBluetoothGattDescriptorClient)); - fake_dbus_thread_manager->SetBluetoothGattServiceClient( + dbus_setter->SetBluetoothGattServiceClient( scoped_ptr<BluetoothGattServiceClient>( new FakeBluetoothGattServiceClient)); - fake_dbus_thread_manager->SetBluetoothInputClient( + dbus_setter->SetBluetoothInputClient( scoped_ptr<BluetoothInputClient>(new FakeBluetoothInputClient)); - fake_dbus_thread_manager->SetBluetoothAgentManagerClient( + dbus_setter->SetBluetoothAgentManagerClient( scoped_ptr<BluetoothAgentManagerClient>( new FakeBluetoothAgentManagerClient)); // Set up a PowerManagerClient instance for PerfProvider. - fake_dbus_thread_manager->SetPowerManagerClient( + dbus_setter->SetPowerManagerClient( scoped_ptr<PowerManagerClient>( PowerManagerClient::Create(STUB_DBUS_CLIENT_IMPLEMENTATION))); - DBusThreadManager::InitializeForTesting(fake_dbus_thread_manager.release()); - // Grab pointers to members of the thread manager for easier testing. fake_bluetooth_adapter_client_ = static_cast<FakeBluetoothAdapterClient*>( DBusThreadManager::Get()->GetBluetoothAdapterClient()); diff --git a/chrome/test/base/testing_io_thread_state.cc b/chrome/test/base/testing_io_thread_state.cc index 759d463..e79423f 100644 --- a/chrome/test/base/testing_io_thread_state.cc +++ b/chrome/test/base/testing_io_thread_state.cc @@ -40,7 +40,7 @@ namespace chrome { TestingIOThreadState::TestingIOThreadState() { #if defined(OS_CHROMEOS) // Needed by IOThread constructor. - chromeos::DBusThreadManager::InitializeWithStub(); + chromeos::DBusThreadManager::Initialize(); chromeos::NetworkHandler::Initialize(); #endif diff --git a/chrome/test/base/view_event_test_platform_part_chromeos.cc b/chrome/test/base/view_event_test_platform_part_chromeos.cc index 9e5e610..007300f 100644 --- a/chrome/test/base/view_event_test_platform_part_chromeos.cc +++ b/chrome/test/base/view_event_test_platform_part_chromeos.cc @@ -41,7 +41,7 @@ ViewEventTestPlatformPartChromeOS::ViewEventTestPlatformPartChromeOS( // Ash Shell can't just live on its own without a browser process, we need to // also create the message center. message_center::MessageCenter::Initialize(); - chromeos::DBusThreadManager::InitializeWithStub(); + chromeos::DBusThreadManager::Initialize(); chromeos::CrasAudioHandler::InitializeForTesting(); chromeos::NetworkHandler::Initialize(); ash::test::TestShellDelegate* shell_delegate = diff --git a/chromeos/audio/cras_audio_handler_unittest.cc b/chromeos/audio/cras_audio_handler_unittest.cc index 58dbe04..dec728e 100644 --- a/chromeos/audio/cras_audio_handler_unittest.cc +++ b/chromeos/audio/cras_audio_handler_unittest.cc @@ -252,7 +252,7 @@ class CrasAudioHandlerTest : public testing::Test { } void SetUpCrasAudioHandler(const AudioNodeList& audio_nodes) { - DBusThreadManager::InitializeWithStub(); + DBusThreadManager::Initialize(); cras_audio_client_stub_ = static_cast<CrasAudioClientStubImpl*>( DBusThreadManager::Get()->GetCrasAudioClient()); cras_audio_client_stub_->SetAudioDevices(audio_nodes); diff --git a/chromeos/chromeos.gyp b/chromeos/chromeos.gyp index 6a28795..563a2b7 100644 --- a/chromeos/chromeos.gyp +++ b/chromeos/chromeos.gyp @@ -155,8 +155,6 @@ 'dbus/fake_bluetooth_profile_service_provider.h', 'dbus/fake_cryptohome_client.cc', 'dbus/fake_cryptohome_client.h', - 'dbus/fake_dbus_thread_manager.cc', - 'dbus/fake_dbus_thread_manager.h', 'dbus/fake_debug_daemon_client.cc', 'dbus/fake_debug_daemon_client.h', 'dbus/fake_easy_unlock_client.cc', diff --git a/chromeos/cryptohome/system_salt_getter_unittest.cc b/chromeos/cryptohome/system_salt_getter_unittest.cc index f1b5230..db6bc7b 100644 --- a/chromeos/cryptohome/system_salt_getter_unittest.cc +++ b/chromeos/cryptohome/system_salt_getter_unittest.cc @@ -7,8 +7,8 @@ #include "base/bind.h" #include "base/message_loop/message_loop.h" #include "base/run_loop.h" +#include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/dbus/fake_cryptohome_client.h" -#include "chromeos/dbus/fake_dbus_thread_manager.h" #include "testing/gtest/include/gtest/gtest.h" namespace chromeos { @@ -25,11 +25,9 @@ class SystemSaltGetterTest : public testing::Test { SystemSaltGetterTest() : fake_cryptohome_client_(NULL) {} virtual void SetUp() OVERRIDE { - FakeDBusThreadManager* dbus_thread_manager = new FakeDBusThreadManager; fake_cryptohome_client_ = new FakeCryptohomeClient; - dbus_thread_manager->SetCryptohomeClient( + DBusThreadManager::GetSetterForTesting()->SetCryptohomeClient( scoped_ptr<CryptohomeClient>(fake_cryptohome_client_)); - DBusThreadManager::InitializeForTesting(dbus_thread_manager); EXPECT_FALSE(SystemSaltGetter::IsInitialized()); SystemSaltGetter::Initialize(); diff --git a/chromeos/dbus/dbus_client.h b/chromeos/dbus/dbus_client.h index e166c5f..e05c667 100644 --- a/chromeos/dbus/dbus_client.h +++ b/chromeos/dbus/dbus_client.h @@ -18,8 +18,6 @@ namespace chromeos { // incorrect calls. Stub clients may lift that restriction however. class DBusClient { protected: - friend class DBusThreadManager; - virtual ~DBusClient() {} // This function is called by DBusThreadManager. Only in unit tests, which @@ -28,6 +26,8 @@ class DBusClient { virtual void Init(dbus::Bus* bus) = 0; private: + friend class DBusThreadManager; + DISALLOW_ASSIGN(DBusClient); }; diff --git a/chromeos/dbus/dbus_client_bundle.cc b/chromeos/dbus/dbus_client_bundle.cc index 22d1a99..159b3f2 100644 --- a/chromeos/dbus/dbus_client_bundle.cc +++ b/chromeos/dbus/dbus_client_bundle.cc @@ -220,7 +220,7 @@ DBusClientBundle::DBusClientBundle() { if (!DBusThreadManager::IsUsingStub(MODEM_MESSAGING)) modem_messaging_client_.reset(ModemMessagingClient::Create()); else - modem_messaging_client_.reset(ModemMessagingClient::Create()); + modem_messaging_client_.reset(new FakeModemMessagingClient); // Create the NFC clients in the correct order based on their dependencies. if (!DBusThreadManager::IsUsingStub(NFC)) { diff --git a/chromeos/dbus/dbus_client_bundle.h b/chromeos/dbus/dbus_client_bundle.h index 9d5d22d..e4710a8 100644 --- a/chromeos/dbus/dbus_client_bundle.h +++ b/chromeos/dbus/dbus_client_bundle.h @@ -80,7 +80,7 @@ class CHROMEOS_EXPORT DBusClientBundle { }; DBusClientBundle(); - virtual ~DBusClientBundle(); + ~DBusClientBundle(); // Initialize proper runtime environment for its dbus clients. void SetupDefaultEnvironment(); @@ -230,6 +230,8 @@ class CHROMEOS_EXPORT DBusClientBundle { } private: + friend class DBusThreadManagerSetter; + scoped_ptr<BluetoothAdapterClient> bluetooth_adapter_client_; scoped_ptr<BluetoothAgentManagerClient> bluetooth_agent_manager_client_; scoped_ptr<BluetoothDeviceClient> bluetooth_device_client_; diff --git a/chromeos/dbus/dbus_thread_manager.cc b/chromeos/dbus/dbus_thread_manager.cc index f2edfad..1df4d0e 100644 --- a/chromeos/dbus/dbus_thread_manager.cc +++ b/chromeos/dbus/dbus_thread_manager.cc @@ -24,7 +24,6 @@ #include "chromeos/dbus/dbus_client_bundle.h" #include "chromeos/dbus/debug_daemon_client.h" #include "chromeos/dbus/easy_unlock_client.h" -#include "chromeos/dbus/fake_dbus_thread_manager.h" #include "chromeos/dbus/gsm_sms_client.h" #include "chromeos/dbus/image_burner_client.h" #include "chromeos/dbus/introspectable_client.h" @@ -53,15 +52,14 @@ namespace chromeos { static DBusThreadManager* g_dbus_thread_manager = NULL; -static DBusThreadManager* g_dbus_thread_manager_for_testing = NULL; +static bool g_using_dbus_thread_manager_for_testing = false; DBusClientBundle::DBusClientTypeMask DBusThreadManager::unstub_client_mask_ = DBusClientBundle::NO_CLIENTS; -// The DBusThreadManager implementation used in production. -class DBusThreadManagerImpl : public DBusThreadManager { - public: - DBusThreadManagerImpl() { +DBusThreadManager::DBusThreadManager() { + dbus::statistics::Initialize(); + if (!DBusThreadManager::IsUsingStub(DBusClientBundle::ALL_CLIENTS)) { // Create the D-Bus thread. base::Thread::Options thread_options; thread_options.message_loop_type = base::MessageLoop::TYPE_IO; @@ -74,197 +72,262 @@ class DBusThreadManagerImpl : public DBusThreadManager { system_bus_options.connection_type = dbus::Bus::PRIVATE; system_bus_options.dbus_task_runner = dbus_thread_->message_loop_proxy(); system_bus_ = new dbus::Bus(system_bus_options); - - CreateDefaultClients(); } - virtual ~DBusThreadManagerImpl() { - // PowerPolicyController's destructor depends on PowerManagerClient. - power_policy_controller_.reset(); + CreateDefaultClients(); +} + +DBusThreadManager::~DBusThreadManager() { + // PowerPolicyController's destructor depends on PowerManagerClient. + power_policy_controller_.reset(); - // Delete all D-Bus clients before shutting down the system bus. - client_bundle_.reset(); + // Delete all D-Bus clients before shutting down the system bus. + client_bundle_.reset(); - // Shut down the bus. During the browser shutdown, it's ok to shut down - // the bus synchronously. + // Shut down the bus. During the browser shutdown, it's ok to shut down + // the bus synchronously. + if (system_bus_) system_bus_->ShutdownOnDBusThreadAndBlock(); - // Stop the D-Bus thread. + // Stop the D-Bus thread. + if (dbus_thread_) dbus_thread_->Stop(); - } - void SetupDefaultEnvironment() { - return client_bundle_->SetupDefaultEnvironment(); - } + dbus::statistics::Shutdown(); - virtual dbus::Bus* GetSystemBus() OVERRIDE { - return system_bus_.get(); - } + if (g_dbus_thread_manager == NULL) + return; // Called form Shutdown() or local test instance. - virtual BluetoothAdapterClient* GetBluetoothAdapterClient() OVERRIDE { - return client_bundle_->bluetooth_adapter_client(); + // There should never be both a global instance and a local instance. + CHECK(this == g_dbus_thread_manager); + if (g_using_dbus_thread_manager_for_testing) { + g_dbus_thread_manager = NULL; + g_using_dbus_thread_manager_for_testing = false; + VLOG(1) << "DBusThreadManager destroyed"; + } else { + LOG(FATAL) << "~DBusThreadManager() called outside of Shutdown()"; } +} - virtual BluetoothAgentManagerClient* GetBluetoothAgentManagerClient() - OVERRIDE { - return client_bundle_->bluetooth_agent_manager_client(); - } +dbus::Bus* DBusThreadManager::GetSystemBus() { + return system_bus_.get(); +} - virtual BluetoothDeviceClient* GetBluetoothDeviceClient() OVERRIDE { - return client_bundle_->bluetooth_device_client(); - } +BluetoothAdapterClient* DBusThreadManager::GetBluetoothAdapterClient() { + return client_bundle_->bluetooth_adapter_client(); +} - virtual BluetoothGattCharacteristicClient* - GetBluetoothGattCharacteristicClient() OVERRIDE { - return client_bundle_->bluetooth_gatt_characteristic_client(); - } +BluetoothAgentManagerClient* +DBusThreadManager::GetBluetoothAgentManagerClient() { + return client_bundle_->bluetooth_agent_manager_client(); +} - virtual BluetoothGattDescriptorClient* GetBluetoothGattDescriptorClient() - OVERRIDE { - return client_bundle_->bluetooth_gatt_descriptor_client(); - } +BluetoothDeviceClient* DBusThreadManager::GetBluetoothDeviceClient() { + return client_bundle_->bluetooth_device_client(); +} - virtual BluetoothGattManagerClient* GetBluetoothGattManagerClient() OVERRIDE { - return client_bundle_->bluetooth_gatt_manager_client(); - } +BluetoothGattCharacteristicClient* +DBusThreadManager::GetBluetoothGattCharacteristicClient() { + return client_bundle_->bluetooth_gatt_characteristic_client(); +} - virtual BluetoothGattServiceClient* GetBluetoothGattServiceClient() OVERRIDE { - return client_bundle_->bluetooth_gatt_service_client(); - } +BluetoothGattDescriptorClient* +DBusThreadManager::GetBluetoothGattDescriptorClient() { + return client_bundle_->bluetooth_gatt_descriptor_client(); +} - virtual BluetoothInputClient* GetBluetoothInputClient() OVERRIDE { - return client_bundle_->bluetooth_input_client(); - } +BluetoothGattManagerClient* +DBusThreadManager::GetBluetoothGattManagerClient() { + return client_bundle_->bluetooth_gatt_manager_client(); +} - virtual BluetoothProfileManagerClient* GetBluetoothProfileManagerClient() - OVERRIDE { - return client_bundle_->bluetooth_profile_manager_client(); - } +BluetoothGattServiceClient* +DBusThreadManager::GetBluetoothGattServiceClient() { + return client_bundle_->bluetooth_gatt_service_client(); +} - virtual CrasAudioClient* GetCrasAudioClient() OVERRIDE { - return client_bundle_->cras_audio_client(); - } +BluetoothInputClient* DBusThreadManager::GetBluetoothInputClient() { + return client_bundle_->bluetooth_input_client(); +} - virtual CrosDisksClient* GetCrosDisksClient() OVERRIDE { - return client_bundle_->cros_disks_client(); - } +BluetoothProfileManagerClient* +DBusThreadManager::GetBluetoothProfileManagerClient() { + return client_bundle_->bluetooth_profile_manager_client(); +} - virtual CryptohomeClient* GetCryptohomeClient() OVERRIDE { - return client_bundle_->cryptohome_client(); - } +CrasAudioClient* DBusThreadManager::GetCrasAudioClient() { + return client_bundle_->cras_audio_client(); +} - virtual DebugDaemonClient* GetDebugDaemonClient() OVERRIDE { - return client_bundle_->debug_daemon_client(); - } +CrosDisksClient* DBusThreadManager::GetCrosDisksClient() { + return client_bundle_->cros_disks_client(); +} - virtual EasyUnlockClient* GetEasyUnlockClient() OVERRIDE { - return client_bundle_->easy_unlock_client(); - } - virtual LorgnetteManagerClient* GetLorgnetteManagerClient() OVERRIDE { - return client_bundle_->lorgnette_manager_client(); - } +CryptohomeClient* DBusThreadManager::GetCryptohomeClient() { + return client_bundle_->cryptohome_client(); +} - virtual ShillDeviceClient* GetShillDeviceClient() OVERRIDE { - return client_bundle_->shill_device_client(); - } +DebugDaemonClient* DBusThreadManager::GetDebugDaemonClient() { + return client_bundle_->debug_daemon_client(); +} - virtual ShillIPConfigClient* GetShillIPConfigClient() OVERRIDE { - return client_bundle_->shill_ipconfig_client(); - } +EasyUnlockClient* DBusThreadManager::GetEasyUnlockClient() { + return client_bundle_->easy_unlock_client(); +} +LorgnetteManagerClient* +DBusThreadManager::GetLorgnetteManagerClient() { + return client_bundle_->lorgnette_manager_client(); +} - virtual ShillManagerClient* GetShillManagerClient() OVERRIDE { - return client_bundle_->shill_manager_client(); - } +ShillDeviceClient* +DBusThreadManager::GetShillDeviceClient() { + return client_bundle_->shill_device_client(); +} - virtual ShillServiceClient* GetShillServiceClient() OVERRIDE { - return client_bundle_->shill_service_client(); - } +ShillIPConfigClient* +DBusThreadManager::GetShillIPConfigClient() { + return client_bundle_->shill_ipconfig_client(); +} - virtual ShillProfileClient* GetShillProfileClient() OVERRIDE { - return client_bundle_->shill_profile_client(); - } +ShillManagerClient* +DBusThreadManager::GetShillManagerClient() { + return client_bundle_->shill_manager_client(); +} - virtual GsmSMSClient* GetGsmSMSClient() OVERRIDE { - return client_bundle_->gsm_sms_client(); - } +ShillServiceClient* +DBusThreadManager::GetShillServiceClient() { + return client_bundle_->shill_service_client(); +} - virtual ImageBurnerClient* GetImageBurnerClient() OVERRIDE { - return client_bundle_->image_burner_client(); - } +ShillProfileClient* +DBusThreadManager::GetShillProfileClient() { + return client_bundle_->shill_profile_client(); +} - virtual IntrospectableClient* GetIntrospectableClient() OVERRIDE { - return client_bundle_->introspectable_client(); - } +GsmSMSClient* DBusThreadManager::GetGsmSMSClient() { + return client_bundle_->gsm_sms_client(); +} - virtual ModemMessagingClient* GetModemMessagingClient() OVERRIDE { - return client_bundle_->modem_messaging_client(); - } +ImageBurnerClient* DBusThreadManager::GetImageBurnerClient() { + return client_bundle_->image_burner_client(); +} - virtual NfcAdapterClient* GetNfcAdapterClient() OVERRIDE { - return client_bundle_->nfc_adapter_client(); - } +IntrospectableClient* DBusThreadManager::GetIntrospectableClient() { + return client_bundle_->introspectable_client(); +} - virtual NfcDeviceClient* GetNfcDeviceClient() OVERRIDE { - return client_bundle_->nfc_device_client(); - } +ModemMessagingClient* DBusThreadManager::GetModemMessagingClient() { + return client_bundle_->modem_messaging_client(); +} - virtual NfcManagerClient* GetNfcManagerClient() OVERRIDE { - return client_bundle_->nfc_manager_client(); - } +NfcAdapterClient* DBusThreadManager::GetNfcAdapterClient() { + return client_bundle_->nfc_adapter_client(); +} - virtual NfcRecordClient* GetNfcRecordClient() OVERRIDE { - return client_bundle_->nfc_record_client(); - } +NfcDeviceClient* DBusThreadManager::GetNfcDeviceClient() { + return client_bundle_->nfc_device_client(); +} - virtual NfcTagClient* GetNfcTagClient() OVERRIDE { - return client_bundle_->nfc_tag_client(); - } +NfcManagerClient* DBusThreadManager::GetNfcManagerClient() { + return client_bundle_->nfc_manager_client(); +} - virtual PermissionBrokerClient* GetPermissionBrokerClient() OVERRIDE { - return client_bundle_->permission_broker_client(); - } +NfcRecordClient* DBusThreadManager::GetNfcRecordClient() { + return client_bundle_->nfc_record_client(); +} - virtual PowerManagerClient* GetPowerManagerClient() OVERRIDE { - return client_bundle_->power_manager_client(); - } +NfcTagClient* DBusThreadManager::GetNfcTagClient() { + return client_bundle_->nfc_tag_client(); +} - virtual SessionManagerClient* GetSessionManagerClient() OVERRIDE { - return client_bundle_->session_manager_client(); - } +PermissionBrokerClient* DBusThreadManager::GetPermissionBrokerClient() { + return client_bundle_->permission_broker_client(); +} - virtual SMSClient* GetSMSClient() OVERRIDE { - return client_bundle_->sms_client(); - } +PowerManagerClient* DBusThreadManager::GetPowerManagerClient() { + return client_bundle_->power_manager_client(); +} - virtual SystemClockClient* GetSystemClockClient() OVERRIDE { - return client_bundle_->system_clock_client(); - } +SessionManagerClient* DBusThreadManager::GetSessionManagerClient() { + return client_bundle_->session_manager_client(); +} - virtual UpdateEngineClient* GetUpdateEngineClient() OVERRIDE { - return client_bundle_->update_engine_client(); - } +SMSClient* DBusThreadManager::GetSMSClient() { + return client_bundle_->sms_client(); +} - virtual PowerPolicyController* GetPowerPolicyController() OVERRIDE { - return power_policy_controller_.get(); - } +SystemClockClient* DBusThreadManager::GetSystemClockClient() { + return client_bundle_->system_clock_client(); +} - private: - // Constructs all clients and stores them in the respective *_client_ member - // variable. - void CreateDefaultClients() { - client_bundle_.reset(new DBusClientBundle()); - // TODO(crbug.com/345586): Move PowerPolicyController out of - // DBusThreadManagerImpl. - power_policy_controller_.reset(new PowerPolicyController); - } +UpdateEngineClient* DBusThreadManager::GetUpdateEngineClient() { + return client_bundle_->update_engine_client(); +} + +PowerPolicyController* DBusThreadManager::GetPowerPolicyController() { + return power_policy_controller_.get(); +} + +void DBusThreadManager::CreateDefaultClients() { + client_bundle_.reset(new DBusClientBundle()); + // TODO(crbug.com/345586): Move PowerPolicyController out of + // DBusThreadManager. + power_policy_controller_.reset(new PowerPolicyController); +} + +void DBusThreadManager::InitializeClients() { + GetBluetoothAdapterClient()->Init(GetSystemBus()); + GetBluetoothAgentManagerClient()->Init(GetSystemBus()); + GetBluetoothDeviceClient()->Init(GetSystemBus()); + GetBluetoothGattCharacteristicClient()->Init(GetSystemBus()); + GetBluetoothGattDescriptorClient()->Init(GetSystemBus()); + GetBluetoothGattManagerClient()->Init(GetSystemBus()); + GetBluetoothGattServiceClient()->Init(GetSystemBus()); + GetBluetoothInputClient()->Init(GetSystemBus()); + GetBluetoothProfileManagerClient()->Init(GetSystemBus()); + GetCrasAudioClient()->Init(GetSystemBus()); + GetCrosDisksClient()->Init(GetSystemBus()); + GetCryptohomeClient()->Init(GetSystemBus()); + GetDebugDaemonClient()->Init(GetSystemBus()); + GetEasyUnlockClient()->Init(GetSystemBus()); + GetGsmSMSClient()->Init(GetSystemBus()); + GetImageBurnerClient()->Init(GetSystemBus()); + GetIntrospectableClient()->Init(GetSystemBus()); + GetLorgnetteManagerClient()->Init(GetSystemBus()); + GetModemMessagingClient()->Init(GetSystemBus()); + GetPermissionBrokerClient()->Init(GetSystemBus()); + GetPowerManagerClient()->Init(GetSystemBus()); + GetSessionManagerClient()->Init(GetSystemBus()); + GetShillDeviceClient()->Init(GetSystemBus()); + GetShillIPConfigClient()->Init(GetSystemBus()); + GetShillManagerClient()->Init(GetSystemBus()); + GetShillServiceClient()->Init(GetSystemBus()); + GetShillProfileClient()->Init(GetSystemBus()); + GetSMSClient()->Init(GetSystemBus()); + GetSystemClockClient()->Init(GetSystemBus()); + GetUpdateEngineClient()->Init(GetSystemBus()); + + // Initialize the NFC clients in the correct order. The order of + // initialization matters due to dependencies that exist between the + // client objects. + GetNfcManagerClient()->Init(GetSystemBus()); + GetNfcAdapterClient()->Init(GetSystemBus()); + GetNfcDeviceClient()->Init(GetSystemBus()); + GetNfcTagClient()->Init(GetSystemBus()); + GetNfcRecordClient()->Init(GetSystemBus()); - scoped_ptr<base::Thread> dbus_thread_; - scoped_refptr<dbus::Bus> system_bus_; - scoped_ptr<DBusClientBundle> client_bundle_; - scoped_ptr<PowerPolicyController> power_policy_controller_; + // PowerPolicyController is dependent on PowerManagerClient, so + // initialize it after the main list of clients. + if (GetPowerPolicyController()) + GetPowerPolicyController()->Init(this); + + // This must be called after the list of clients so they've each had a + // chance to register with their object g_dbus_thread_managers. + if (GetSystemBus()) + GetSystemBus()->GetManagedObjects(); - DISALLOW_COPY_AND_ASSIGN(DBusThreadManagerImpl); -}; + client_bundle_->SetupDefaultEnvironment(); +} // static bool DBusThreadManager::IsUsingStub(DBusClientBundle::DBusClientType client) { @@ -275,15 +338,10 @@ bool DBusThreadManager::IsUsingStub(DBusClientBundle::DBusClientType client) { void DBusThreadManager::Initialize() { // If we initialize DBusThreadManager twice we may also be shutting it down // early; do not allow that. - CHECK(g_dbus_thread_manager == NULL); - - if (g_dbus_thread_manager_for_testing) { - g_dbus_thread_manager = g_dbus_thread_manager_for_testing; - InitializeClients(); - VLOG(1) << "DBusThreadManager initialized with test implementation"; + if (g_using_dbus_thread_manager_for_testing) return; - } + CHECK(g_dbus_thread_manager == NULL); bool use_dbus_stub = !base::SysInfo::IsRunningOnChromeOS() || CommandLine::ForCurrentProcess()->HasSwitch( chromeos::switches::kDbusStub); @@ -295,43 +353,46 @@ void DBusThreadManager::Initialize() { CommandLine::ForCurrentProcess()->GetSwitchValueASCII( chromeos::switches::kDbusUnstubClients)); } else if (use_dbus_stub) { - InitializeWithStub(); + InitializeWithStubs(); } else { InitializeRegular(); } } // static -void DBusThreadManager::SetInstanceForTesting( - DBusThreadManager* dbus_thread_manager) { - CHECK(!g_dbus_thread_manager); - CHECK(!g_dbus_thread_manager_for_testing); - g_dbus_thread_manager_for_testing = dbus_thread_manager; +scoped_ptr<DBusThreadManagerSetter> DBusThreadManager::GetSetterForTesting() { + if (!g_using_dbus_thread_manager_for_testing) { + g_using_dbus_thread_manager_for_testing = true; + InitializeWithStubs(); + } + + return make_scoped_ptr(new DBusThreadManagerSetter()); } // static -void DBusThreadManager::InitializeForTesting( - DBusThreadManager* dbus_thread_manager) { - unstub_client_mask_ = DBusClientBundle::NO_CLIENTS; - SetInstanceForTesting(dbus_thread_manager); - Initialize(); +void DBusThreadManager::CreateGlobalInstance() { + CHECK(!g_dbus_thread_manager); + g_dbus_thread_manager = new DBusThreadManager(); + g_dbus_thread_manager->InitializeClients(); } // static void DBusThreadManager::InitializeRegular() { unstub_client_mask_ = DBusClientBundle::ALL_CLIENTS; - g_dbus_thread_manager = new DBusThreadManagerImpl(); - InitializeClients(); + CreateGlobalInstance(); VLOG(1) << "DBusThreadManager initialized for Chrome OS"; } // static +void DBusThreadManager::InitializeWithStubs() { + unstub_client_mask_ = DBusClientBundle::NO_CLIENTS; + CreateGlobalInstance(); + VLOG(1) << "DBusThreadManager created for testing"; +} + +// static void DBusThreadManager::InitializeWithPartialStub( const std::string& unstub_clients) { - // If we initialize DBusThreadManager twice we may also be shutting it down - // early; do not allow that. - CHECK(g_dbus_thread_manager == NULL); - unstub_client_mask_ = DBusClientBundle::ParseUnstubList(unstub_clients); // We should have something parsed correctly here. if (unstub_client_mask_ == 0) { @@ -340,25 +401,8 @@ void DBusThreadManager::InitializeWithPartialStub( << " cannot be parsed: " << unstub_clients; } - DBusThreadManagerImpl* dbus_thread_manager = new DBusThreadManagerImpl(); VLOG(1) << "DBusThreadManager initialized for mixed runtime environment"; - g_dbus_thread_manager = dbus_thread_manager; - InitializeClients(); - dbus_thread_manager->SetupDefaultEnvironment(); -} - -// static -void DBusThreadManager::InitializeWithStub() { - unstub_client_mask_ = DBusClientBundle::NO_CLIENTS; - // If we initialize DBusThreadManager twice we may also be shutting it down - // early; do not allow that. - CHECK(g_dbus_thread_manager == NULL); - FakeDBusThreadManager* fake_dbus_thread_manager = new FakeDBusThreadManager; - fake_dbus_thread_manager->SetFakeClients(); - g_dbus_thread_manager = fake_dbus_thread_manager; - InitializeClients(); - fake_dbus_thread_manager->SetupDefaultEnvironment(); - VLOG(1) << "DBusThreadManager initialized with stub implementation"; + CreateGlobalInstance(); } // static @@ -368,35 +412,15 @@ bool DBusThreadManager::IsInitialized() { // static void DBusThreadManager::Shutdown() { - // If we called InitializeForTesting, this may get called more than once. // Ensure that we only shutdown DBusThreadManager once. - CHECK(g_dbus_thread_manager || g_dbus_thread_manager_for_testing); + CHECK(g_dbus_thread_manager); DBusThreadManager* dbus_thread_manager = g_dbus_thread_manager; g_dbus_thread_manager = NULL; - g_dbus_thread_manager_for_testing = NULL; + g_using_dbus_thread_manager_for_testing = false; delete dbus_thread_manager; VLOG(1) << "DBusThreadManager Shutdown completed"; } -DBusThreadManager::DBusThreadManager() { - dbus::statistics::Initialize(); -} - -DBusThreadManager::~DBusThreadManager() { - dbus::statistics::Shutdown(); - if (g_dbus_thread_manager == NULL) - return; // Called form Shutdown() or local test instance. - // There should never be both a global instance and a local instance. - CHECK(this == g_dbus_thread_manager); - if (g_dbus_thread_manager_for_testing) { - g_dbus_thread_manager = NULL; - g_dbus_thread_manager_for_testing = NULL; - VLOG(1) << "DBusThreadManager destroyed"; - } else { - LOG(FATAL) << "~DBusThreadManager() called outside of Shutdown()"; - } -} - // static DBusThreadManager* DBusThreadManager::Get() { CHECK(g_dbus_thread_manager) @@ -404,65 +428,213 @@ DBusThreadManager* DBusThreadManager::Get() { return g_dbus_thread_manager; } -// static -void DBusThreadManager::InitializeClients() { - InitClient(g_dbus_thread_manager->GetBluetoothAdapterClient()); - InitClient(g_dbus_thread_manager->GetBluetoothAgentManagerClient()); - InitClient(g_dbus_thread_manager->GetBluetoothDeviceClient()); - InitClient(g_dbus_thread_manager->GetBluetoothGattCharacteristicClient()); - InitClient(g_dbus_thread_manager->GetBluetoothGattDescriptorClient()); - InitClient(g_dbus_thread_manager->GetBluetoothGattManagerClient()); - InitClient(g_dbus_thread_manager->GetBluetoothGattServiceClient()); - InitClient(g_dbus_thread_manager->GetBluetoothInputClient()); - InitClient(g_dbus_thread_manager->GetBluetoothProfileManagerClient()); - InitClient(g_dbus_thread_manager->GetCrasAudioClient()); - InitClient(g_dbus_thread_manager->GetCrosDisksClient()); - InitClient(g_dbus_thread_manager->GetCryptohomeClient()); - InitClient(g_dbus_thread_manager->GetDebugDaemonClient()); - InitClient(g_dbus_thread_manager->GetEasyUnlockClient()); - InitClient(g_dbus_thread_manager->GetGsmSMSClient()); - InitClient(g_dbus_thread_manager->GetImageBurnerClient()); - InitClient(g_dbus_thread_manager->GetIntrospectableClient()); - InitClient(g_dbus_thread_manager->GetLorgnetteManagerClient()); - InitClient(g_dbus_thread_manager->GetModemMessagingClient()); - InitClient(g_dbus_thread_manager->GetPermissionBrokerClient()); - InitClient(g_dbus_thread_manager->GetPowerManagerClient()); - InitClient(g_dbus_thread_manager->GetSessionManagerClient()); - InitClient(g_dbus_thread_manager->GetShillDeviceClient()); - InitClient(g_dbus_thread_manager->GetShillIPConfigClient()); - InitClient(g_dbus_thread_manager->GetShillManagerClient()); - InitClient(g_dbus_thread_manager->GetShillServiceClient()); - InitClient(g_dbus_thread_manager->GetShillProfileClient()); - InitClient(g_dbus_thread_manager->GetSMSClient()); - InitClient(g_dbus_thread_manager->GetSystemClockClient()); - InitClient(g_dbus_thread_manager->GetUpdateEngineClient()); +DBusThreadManagerSetter::DBusThreadManagerSetter() { +} - // Initialize the NFC clients in the correct order. The order of - // initialization matters due to dependencies that exist between the - // client objects. - InitClient(g_dbus_thread_manager->GetNfcManagerClient()); - InitClient(g_dbus_thread_manager->GetNfcAdapterClient()); - InitClient(g_dbus_thread_manager->GetNfcDeviceClient()); - InitClient(g_dbus_thread_manager->GetNfcTagClient()); - InitClient(g_dbus_thread_manager->GetNfcRecordClient()); +DBusThreadManagerSetter::~DBusThreadManagerSetter() { +} - // PowerPolicyController is dependent on PowerManagerClient, so - // initialize it after the main list of clients. - if (g_dbus_thread_manager->GetPowerPolicyController()) { - g_dbus_thread_manager->GetPowerPolicyController()->Init( - g_dbus_thread_manager); - } +void DBusThreadManagerSetter::SetBluetoothAdapterClient( + scoped_ptr<BluetoothAdapterClient> client) { + DBusThreadManager::Get()->client_bundle_->bluetooth_adapter_client_ = + client.Pass(); +} - // This must be called after the list of clients so they've each had a - // chance to register with their object g_dbus_thread_managers. - if (g_dbus_thread_manager->GetSystemBus()) - g_dbus_thread_manager->GetSystemBus()->GetManagedObjects(); +void DBusThreadManagerSetter::SetBluetoothAgentManagerClient( + scoped_ptr<BluetoothAgentManagerClient> client) { + DBusThreadManager::Get()->client_bundle_->bluetooth_agent_manager_client_ = + client.Pass(); } -// static -void DBusThreadManager::InitClient(DBusClient* client) { - if (client) - client->Init(g_dbus_thread_manager->GetSystemBus()); +void DBusThreadManagerSetter::SetBluetoothDeviceClient( + scoped_ptr<BluetoothDeviceClient> client) { + DBusThreadManager::Get()->client_bundle_->bluetooth_device_client_ = + client.Pass(); +} + +void DBusThreadManagerSetter::SetBluetoothGattCharacteristicClient( + scoped_ptr<BluetoothGattCharacteristicClient> client) { + DBusThreadManager::Get()->client_bundle_-> + bluetooth_gatt_characteristic_client_ = client.Pass(); +} + +void DBusThreadManagerSetter::SetBluetoothGattDescriptorClient( + scoped_ptr<BluetoothGattDescriptorClient> client) { + DBusThreadManager::Get()->client_bundle_->bluetooth_gatt_descriptor_client_ = + client.Pass(); +} + +void DBusThreadManagerSetter::SetBluetoothGattManagerClient( + scoped_ptr<BluetoothGattManagerClient> client) { + DBusThreadManager::Get()->client_bundle_->bluetooth_gatt_manager_client_ = + client.Pass(); +} + +void DBusThreadManagerSetter::SetBluetoothGattServiceClient( + scoped_ptr<BluetoothGattServiceClient> client) { + DBusThreadManager::Get()->client_bundle_->bluetooth_gatt_service_client_ = + client.Pass(); +} + +void DBusThreadManagerSetter::SetBluetoothInputClient( + scoped_ptr<BluetoothInputClient> client) { + DBusThreadManager::Get()->client_bundle_->bluetooth_input_client_ = + client.Pass(); +} + +void DBusThreadManagerSetter::SetBluetoothProfileManagerClient( + scoped_ptr<BluetoothProfileManagerClient> client) { + DBusThreadManager::Get()->client_bundle_->bluetooth_profile_manager_client_ = + client.Pass(); +} + +void DBusThreadManagerSetter::SetCrasAudioClient( + scoped_ptr<CrasAudioClient> client) { + DBusThreadManager::Get()->client_bundle_->cras_audio_client_ = client.Pass(); +} + +void DBusThreadManagerSetter::SetCrosDisksClient( + scoped_ptr<CrosDisksClient> client) { + DBusThreadManager::Get()->client_bundle_->cros_disks_client_ = client.Pass(); +} + +void DBusThreadManagerSetter::SetCryptohomeClient( + scoped_ptr<CryptohomeClient> client) { + DBusThreadManager::Get()->client_bundle_->cryptohome_client_ = client.Pass(); +} + +void DBusThreadManagerSetter::SetDebugDaemonClient( + scoped_ptr<DebugDaemonClient> client) { + DBusThreadManager::Get()->client_bundle_->debug_daemon_client_ = + client.Pass(); +} + +void DBusThreadManagerSetter::SetEasyUnlockClient( + scoped_ptr<EasyUnlockClient> client) { + DBusThreadManager::Get()->client_bundle_->easy_unlock_client_ = client.Pass(); +} + +void DBusThreadManagerSetter::SetLorgnetteManagerClient( + scoped_ptr<LorgnetteManagerClient> client) { + DBusThreadManager::Get()->client_bundle_->lorgnette_manager_client_ = + client.Pass(); +} + +void DBusThreadManagerSetter::SetShillDeviceClient( + scoped_ptr<ShillDeviceClient> client) { + DBusThreadManager::Get()->client_bundle_->shill_device_client_ = + client.Pass(); +} + +void DBusThreadManagerSetter::SetShillIPConfigClient( + scoped_ptr<ShillIPConfigClient> client) { + DBusThreadManager::Get()->client_bundle_->shill_ipconfig_client_ = + client.Pass(); +} + +void DBusThreadManagerSetter::SetShillManagerClient( + scoped_ptr<ShillManagerClient> client) { + DBusThreadManager::Get()->client_bundle_->shill_manager_client_ = + client.Pass(); +} + +void DBusThreadManagerSetter::SetShillServiceClient( + scoped_ptr<ShillServiceClient> client) { + DBusThreadManager::Get()->client_bundle_->shill_service_client_ = + client.Pass(); +} + +void DBusThreadManagerSetter::SetShillProfileClient( + scoped_ptr<ShillProfileClient> client) { + DBusThreadManager::Get()->client_bundle_->shill_profile_client_ = + client.Pass(); +} + +void DBusThreadManagerSetter::SetGsmSMSClient( + scoped_ptr<GsmSMSClient> client) { + DBusThreadManager::Get()->client_bundle_->gsm_sms_client_ = client.Pass(); +} + +void DBusThreadManagerSetter::SetImageBurnerClient( + scoped_ptr<ImageBurnerClient> client) { + DBusThreadManager::Get()->client_bundle_->image_burner_client_ = + client.Pass(); +} + +void DBusThreadManagerSetter::SetIntrospectableClient( + scoped_ptr<IntrospectableClient> client) { + DBusThreadManager::Get()->client_bundle_->introspectable_client_ = + client.Pass(); +} + +void DBusThreadManagerSetter::SetModemMessagingClient( + scoped_ptr<ModemMessagingClient> client) { + DBusThreadManager::Get()->client_bundle_->modem_messaging_client_ = + client.Pass(); +} + +void DBusThreadManagerSetter::SetNfcAdapterClient( + scoped_ptr<NfcAdapterClient> client) { + DBusThreadManager::Get()->client_bundle_->nfc_adapter_client_ = client.Pass(); +} + +void DBusThreadManagerSetter::SetNfcDeviceClient( + scoped_ptr<NfcDeviceClient> client) { + DBusThreadManager::Get()->client_bundle_->nfc_device_client_ = client.Pass(); +} + +void DBusThreadManagerSetter::SetNfcManagerClient( + scoped_ptr<NfcManagerClient> client) { + DBusThreadManager::Get()->client_bundle_->nfc_manager_client_ = client.Pass(); +} + +void DBusThreadManagerSetter::SetNfcRecordClient( + scoped_ptr<NfcRecordClient> client) { + DBusThreadManager::Get()->client_bundle_->nfc_record_client_ = client.Pass(); +} + +void DBusThreadManagerSetter::SetNfcTagClient( + scoped_ptr<NfcTagClient> client) { + DBusThreadManager::Get()->client_bundle_->nfc_tag_client_ = client.Pass(); +} + +void DBusThreadManagerSetter::SetPermissionBrokerClient( + scoped_ptr<PermissionBrokerClient> client) { + DBusThreadManager::Get()->client_bundle_->permission_broker_client_ = + client.Pass(); +} + +void DBusThreadManagerSetter::SetPowerManagerClient( + scoped_ptr<PowerManagerClient> client) { + DBusThreadManager::Get()->power_policy_controller_.reset(); + DBusThreadManager::Get()->client_bundle_->power_manager_client_ = + client.Pass(); + DBusThreadManager::Get()->power_policy_controller_.reset( + new PowerPolicyController); + DBusThreadManager::Get()->power_policy_controller_->Init( + DBusThreadManager::Get()); +} + +void DBusThreadManagerSetter::SetSessionManagerClient( + scoped_ptr<SessionManagerClient> client) { + DBusThreadManager::Get()->client_bundle_->session_manager_client_ = + client.Pass(); +} + +void DBusThreadManagerSetter::SetSMSClient(scoped_ptr<SMSClient> client) { + DBusThreadManager::Get()->client_bundle_->sms_client_ = client.Pass(); +} + +void DBusThreadManagerSetter::SetSystemClockClient( + scoped_ptr<SystemClockClient> client) { + DBusThreadManager::Get()->client_bundle_->system_clock_client_ = + client.Pass(); +} + +void DBusThreadManagerSetter::SetUpdateEngineClient( + scoped_ptr<UpdateEngineClient> client) { + DBusThreadManager::Get()->client_bundle_->update_engine_client_ = + client.Pass(); } } // namespace chromeos diff --git a/chromeos/dbus/dbus_thread_manager.h b/chromeos/dbus/dbus_thread_manager.h index 053763c..f190f66 100644 --- a/chromeos/dbus/dbus_thread_manager.h +++ b/chromeos/dbus/dbus_thread_manager.h @@ -36,6 +36,8 @@ class CrasAudioClient; class CrosDisksClient; class CryptohomeClient; class DBusClient; +class DBusThreadManager; +class DBusThreadManagerSetter; class DebugDaemonClient; class EasyUnlockClient; class GsmSMSClient; @@ -86,24 +88,9 @@ class CHROMEOS_EXPORT DBusThreadManager { // making it a Singleton, to ensure clean startup and shutdown. static void Initialize(); - // Sets an alternative DBusThreadManager such as MockDBusThreadManager - // to be used in |Initialize()| for testing. Tests that call - // DBusThreadManager::Initialize() (such as browser_tests and - // interactive_ui_tests) should use this instead of calling - // |InitiailzeForTesting|. The injected object will be owned by the - // internal pointer and deleted by Shutdown(). - static void SetInstanceForTesting(DBusThreadManager* dbus_thread_manager); - - // Similar to Initialize(), but injects an alternative - // DBusThreadManager using SetInstanceForTest first. The injected - // object will be owned by the internal pointer and deleted by - // Shutdown(). Does not create any Fake client implementations. - static void InitializeForTesting(DBusThreadManager* dbus_thread_manager); - - // Initialize with stub implementations for tests, creating a complete set - // of fake/stub client implementations. Also initializes a default set of - // fake Shill devices and services, customizable with switches::kShillStub. - static void InitializeWithStub(); + // Returns DBusThreadManagerSetter instance that allows tests to + // replace individual dbus clients with their own implementations. + static scoped_ptr<DBusThreadManagerSetter> GetSetterForTesting(); // Returns true if DBusThreadManager has been initialized. Call this to // avoid initializing + shutting down DBusThreadManager more than once. @@ -119,76 +106,142 @@ class CHROMEOS_EXPORT DBusThreadManager { static bool IsUsingStub(DBusClientBundle::DBusClientType client); // Returns various D-Bus bus instances, owned by DBusThreadManager. - virtual dbus::Bus* GetSystemBus() = 0; + dbus::Bus* GetSystemBus(); // All returned objects are owned by DBusThreadManager. Do not cache these // pointers and use them after DBusThreadManager has been shut down. - virtual BluetoothAdapterClient* GetBluetoothAdapterClient() = 0; - virtual BluetoothAgentManagerClient* GetBluetoothAgentManagerClient() = 0; - virtual BluetoothDeviceClient* GetBluetoothDeviceClient() = 0; - virtual BluetoothGattCharacteristicClient* - GetBluetoothGattCharacteristicClient() = 0; - virtual BluetoothGattDescriptorClient* GetBluetoothGattDescriptorClient() = 0; - virtual BluetoothGattManagerClient* GetBluetoothGattManagerClient() = 0; - virtual BluetoothGattServiceClient* GetBluetoothGattServiceClient() = 0; - virtual BluetoothInputClient* GetBluetoothInputClient() = 0; - virtual BluetoothProfileManagerClient* GetBluetoothProfileManagerClient() = 0; - virtual CrasAudioClient* GetCrasAudioClient() = 0; - virtual CrosDisksClient* GetCrosDisksClient() = 0; - virtual CryptohomeClient* GetCryptohomeClient() = 0; - virtual DebugDaemonClient* GetDebugDaemonClient() = 0; - virtual EasyUnlockClient* GetEasyUnlockClient() = 0; - virtual GsmSMSClient* GetGsmSMSClient() = 0; - virtual ImageBurnerClient* GetImageBurnerClient() = 0; - virtual IntrospectableClient* GetIntrospectableClient() = 0; - virtual LorgnetteManagerClient* GetLorgnetteManagerClient() = 0; - virtual ModemMessagingClient* GetModemMessagingClient() = 0; - virtual NfcAdapterClient* GetNfcAdapterClient() = 0; - virtual NfcDeviceClient* GetNfcDeviceClient() = 0; - virtual NfcManagerClient* GetNfcManagerClient() = 0; - virtual NfcRecordClient* GetNfcRecordClient() = 0; - virtual NfcTagClient* GetNfcTagClient() = 0; - virtual PermissionBrokerClient* GetPermissionBrokerClient() = 0; - virtual PowerManagerClient* GetPowerManagerClient() = 0; - virtual PowerPolicyController* GetPowerPolicyController() = 0; - virtual SessionManagerClient* GetSessionManagerClient() = 0; - virtual ShillDeviceClient* GetShillDeviceClient() = 0; - virtual ShillIPConfigClient* GetShillIPConfigClient() = 0; - virtual ShillManagerClient* GetShillManagerClient() = 0; - virtual ShillServiceClient* GetShillServiceClient() = 0; - virtual ShillProfileClient* GetShillProfileClient() = 0; - virtual SMSClient* GetSMSClient() = 0; - virtual SystemClockClient* GetSystemClockClient() = 0; - virtual UpdateEngineClient* GetUpdateEngineClient() = 0; - - virtual ~DBusThreadManager(); - - protected: - DBusThreadManager(); + BluetoothAdapterClient* GetBluetoothAdapterClient(); + BluetoothAgentManagerClient* GetBluetoothAgentManagerClient(); + BluetoothDeviceClient* GetBluetoothDeviceClient(); + BluetoothGattCharacteristicClient* GetBluetoothGattCharacteristicClient(); + BluetoothGattDescriptorClient* GetBluetoothGattDescriptorClient(); + BluetoothGattManagerClient* GetBluetoothGattManagerClient(); + BluetoothGattServiceClient* GetBluetoothGattServiceClient(); + BluetoothInputClient* GetBluetoothInputClient(); + BluetoothProfileManagerClient* GetBluetoothProfileManagerClient(); + CrasAudioClient* GetCrasAudioClient(); + CrosDisksClient* GetCrosDisksClient(); + CryptohomeClient* GetCryptohomeClient(); + DebugDaemonClient* GetDebugDaemonClient(); + EasyUnlockClient* GetEasyUnlockClient(); + GsmSMSClient* GetGsmSMSClient(); + ImageBurnerClient* GetImageBurnerClient(); + IntrospectableClient* GetIntrospectableClient(); + LorgnetteManagerClient* GetLorgnetteManagerClient(); + ModemMessagingClient* GetModemMessagingClient(); + NfcAdapterClient* GetNfcAdapterClient(); + NfcDeviceClient* GetNfcDeviceClient(); + NfcManagerClient* GetNfcManagerClient(); + NfcRecordClient* GetNfcRecordClient(); + NfcTagClient* GetNfcTagClient(); + PermissionBrokerClient* GetPermissionBrokerClient(); + PowerManagerClient* GetPowerManagerClient(); + PowerPolicyController* GetPowerPolicyController(); + SessionManagerClient* GetSessionManagerClient(); + ShillDeviceClient* GetShillDeviceClient(); + ShillIPConfigClient* GetShillIPConfigClient(); + ShillManagerClient* GetShillManagerClient(); + ShillServiceClient* GetShillServiceClient(); + ShillProfileClient* GetShillProfileClient(); + SMSClient* GetSMSClient(); + SystemClockClient* GetSystemClockClient(); + UpdateEngineClient* GetUpdateEngineClient(); private: + friend class DBusThreadManagerSetter; + + DBusThreadManager(); + ~DBusThreadManager(); + + // Creates a global instance of DBusThreadManager. Can not be called more + // than once. + static void CreateGlobalInstance(); + // Initialize global thread manager instance. static void InitializeRegular(); + // Initialize global thread manager instance with stubbed-out dbus clients + // implementation. + static void InitializeWithStubs(); + // Initialize with stub implementations for only certain clients that are // not included in comma-separated |unstub_clients| list. static void InitializeWithPartialStub(const std::string& unstub_clients); - // InitializeClients is called after g_dbus_thread_manager is set. - // NOTE: Clients that access other clients in their Init() must be - // initialized in the correct order. - static void InitializeClients(); + // Constructs all clients and stores them in the respective *_client_ member + // variable. + void CreateDefaultClients(); - // Initializes |client| with the |system_bus_|. - static void InitClient(DBusClient* client); + // Constructs all clients and stores them in the respective *_client_ member + // variable. + void InitializeClients(); // Bitmask that defines which dbus clients are not stubbed out. Bitmap flags // are defined within DBusClientBundle::DBusClientType enum. static DBusClientBundle::DBusClientTypeMask unstub_client_mask_; + scoped_ptr<base::Thread> dbus_thread_; + scoped_refptr<dbus::Bus> system_bus_; + scoped_ptr<DBusClientBundle> client_bundle_; + scoped_ptr<PowerPolicyController> power_policy_controller_; + DISALLOW_COPY_AND_ASSIGN(DBusThreadManager); }; +class CHROMEOS_EXPORT DBusThreadManagerSetter { + public: + ~DBusThreadManagerSetter(); + + void SetBluetoothAdapterClient(scoped_ptr<BluetoothAdapterClient> client); + void SetBluetoothAgentManagerClient( + scoped_ptr<BluetoothAgentManagerClient> client); + void SetBluetoothDeviceClient(scoped_ptr<BluetoothDeviceClient> client); + void SetBluetoothGattCharacteristicClient( + scoped_ptr<BluetoothGattCharacteristicClient> client); + void SetBluetoothGattDescriptorClient( + scoped_ptr<BluetoothGattDescriptorClient> client); + void SetBluetoothGattManagerClient( + scoped_ptr<BluetoothGattManagerClient> client); + void SetBluetoothGattServiceClient( + scoped_ptr<BluetoothGattServiceClient> client); + void SetBluetoothInputClient(scoped_ptr<BluetoothInputClient> client); + void SetBluetoothProfileManagerClient( + scoped_ptr<BluetoothProfileManagerClient> client); + void SetCrasAudioClient(scoped_ptr<CrasAudioClient> client); + void SetCrosDisksClient(scoped_ptr<CrosDisksClient> client); + void SetCryptohomeClient(scoped_ptr<CryptohomeClient> client); + void SetDebugDaemonClient(scoped_ptr<DebugDaemonClient> client); + void SetEasyUnlockClient(scoped_ptr<EasyUnlockClient> client); + void SetLorgnetteManagerClient(scoped_ptr<LorgnetteManagerClient> client); + void SetShillDeviceClient(scoped_ptr<ShillDeviceClient> client); + void SetShillIPConfigClient(scoped_ptr<ShillIPConfigClient> client); + void SetShillManagerClient(scoped_ptr<ShillManagerClient> client); + void SetShillServiceClient(scoped_ptr<ShillServiceClient> client); + void SetShillProfileClient(scoped_ptr<ShillProfileClient> client); + void SetGsmSMSClient(scoped_ptr<GsmSMSClient> client); + void SetImageBurnerClient(scoped_ptr<ImageBurnerClient> client); + void SetIntrospectableClient(scoped_ptr<IntrospectableClient> client); + void SetModemMessagingClient(scoped_ptr<ModemMessagingClient> client); + void SetNfcAdapterClient(scoped_ptr<NfcAdapterClient> client); + void SetNfcDeviceClient(scoped_ptr<NfcDeviceClient> client); + void SetNfcManagerClient(scoped_ptr<NfcManagerClient> client); + void SetNfcRecordClient(scoped_ptr<NfcRecordClient> client); + void SetNfcTagClient(scoped_ptr<NfcTagClient> client); + void SetPermissionBrokerClient(scoped_ptr<PermissionBrokerClient> client); + void SetPowerManagerClient(scoped_ptr<PowerManagerClient> client); + void SetSessionManagerClient(scoped_ptr<SessionManagerClient> client); + void SetSMSClient(scoped_ptr<SMSClient> client); + void SetSystemClockClient(scoped_ptr<SystemClockClient> client); + void SetUpdateEngineClient(scoped_ptr<UpdateEngineClient> client); + + private: + friend class DBusThreadManager; + + DBusThreadManagerSetter(); + + DISALLOW_COPY_AND_ASSIGN(DBusThreadManagerSetter); +}; + } // namespace chromeos #endif // CHROMEOS_DBUS_DBUS_THREAD_MANAGER_H_ diff --git a/chromeos/dbus/fake_dbus_thread_manager.cc b/chromeos/dbus/fake_dbus_thread_manager.cc deleted file mode 100644 index abf26e9..0000000 --- a/chromeos/dbus/fake_dbus_thread_manager.cc +++ /dev/null @@ -1,472 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chromeos/dbus/fake_dbus_thread_manager.h" - -#include "base/command_line.h" -#include "chromeos/chromeos_switches.h" -#include "chromeos/dbus/cras_audio_client_stub_impl.h" -#include "chromeos/dbus/cros_disks_client.h" -#include "chromeos/dbus/dbus_client.h" -#include "chromeos/dbus/dbus_thread_manager.h" -#include "chromeos/dbus/fake_bluetooth_adapter_client.h" -#include "chromeos/dbus/fake_bluetooth_agent_manager_client.h" -#include "chromeos/dbus/fake_bluetooth_device_client.h" -#include "chromeos/dbus/fake_bluetooth_gatt_characteristic_client.h" -#include "chromeos/dbus/fake_bluetooth_gatt_descriptor_client.h" -#include "chromeos/dbus/fake_bluetooth_gatt_manager_client.h" -#include "chromeos/dbus/fake_bluetooth_gatt_service_client.h" -#include "chromeos/dbus/fake_bluetooth_input_client.h" -#include "chromeos/dbus/fake_bluetooth_profile_manager_client.h" -#include "chromeos/dbus/fake_cryptohome_client.h" -#include "chromeos/dbus/fake_debug_daemon_client.h" -#include "chromeos/dbus/fake_easy_unlock_client.h" -#include "chromeos/dbus/fake_gsm_sms_client.h" -#include "chromeos/dbus/fake_image_burner_client.h" -#include "chromeos/dbus/fake_introspectable_client.h" -#include "chromeos/dbus/fake_lorgnette_manager_client.h" -#include "chromeos/dbus/fake_modem_messaging_client.h" -#include "chromeos/dbus/fake_nfc_adapter_client.h" -#include "chromeos/dbus/fake_nfc_device_client.h" -#include "chromeos/dbus/fake_nfc_manager_client.h" -#include "chromeos/dbus/fake_nfc_record_client.h" -#include "chromeos/dbus/fake_nfc_tag_client.h" -#include "chromeos/dbus/fake_permission_broker_client.h" -#include "chromeos/dbus/fake_shill_device_client.h" -#include "chromeos/dbus/fake_shill_ipconfig_client.h" -#include "chromeos/dbus/fake_shill_manager_client.h" -#include "chromeos/dbus/fake_shill_profile_client.h" -#include "chromeos/dbus/fake_shill_service_client.h" -#include "chromeos/dbus/fake_sms_client.h" -#include "chromeos/dbus/fake_system_clock_client.h" -#include "chromeos/dbus/power_manager_client.h" -#include "chromeos/dbus/power_policy_controller.h" -#include "chromeos/dbus/session_manager_client.h" -#include "chromeos/dbus/update_engine_client.h" - -namespace chromeos { - -FakeDBusThreadManager::FakeDBusThreadManager() { -} - -FakeDBusThreadManager::~FakeDBusThreadManager() { -} - -void FakeDBusThreadManager::SetFakeClients() { - const DBusClientImplementationType client_type = - STUB_DBUS_CLIENT_IMPLEMENTATION; - SetBluetoothAdapterClient( - scoped_ptr<BluetoothAdapterClient>(new FakeBluetoothAdapterClient)); - SetBluetoothAgentManagerClient(scoped_ptr<BluetoothAgentManagerClient>( - new FakeBluetoothAgentManagerClient)); - SetBluetoothDeviceClient( - scoped_ptr<BluetoothDeviceClient>(new FakeBluetoothDeviceClient)); - SetBluetoothGattCharacteristicClient( - scoped_ptr<BluetoothGattCharacteristicClient>( - new FakeBluetoothGattCharacteristicClient)); - SetBluetoothGattDescriptorClient(scoped_ptr<BluetoothGattDescriptorClient>( - new FakeBluetoothGattDescriptorClient)); - SetBluetoothGattManagerClient(scoped_ptr<BluetoothGattManagerClient>( - new FakeBluetoothGattManagerClient)); - SetBluetoothGattServiceClient(scoped_ptr<BluetoothGattServiceClient>( - new FakeBluetoothGattServiceClient)); - SetBluetoothInputClient( - scoped_ptr<BluetoothInputClient>(new FakeBluetoothInputClient)); - SetBluetoothProfileManagerClient(scoped_ptr<BluetoothProfileManagerClient>( - new FakeBluetoothProfileManagerClient)); - SetCrosDisksClient( - scoped_ptr<CrosDisksClient>(CrosDisksClient::Create(client_type))); - SetCrasAudioClient(scoped_ptr<CrasAudioClient>(new CrasAudioClientStubImpl)); - SetCryptohomeClient(scoped_ptr<CryptohomeClient>(new FakeCryptohomeClient)); - SetDebugDaemonClient( - scoped_ptr<DebugDaemonClient>(new FakeDebugDaemonClient)); - SetEasyUnlockClient(scoped_ptr<EasyUnlockClient>(new FakeEasyUnlockClient)); - SetLorgnetteManagerClient( - scoped_ptr<LorgnetteManagerClient>(new FakeLorgnetteManagerClient)); - - SetFakeShillClients(); - - FakeGsmSMSClient* gsm_sms_client = new FakeGsmSMSClient(); - gsm_sms_client->set_sms_test_message_switch_present( - CommandLine::ForCurrentProcess()->HasSwitch( - chromeos::switches::kSmsTestMessages)); - SetGsmSMSClient(scoped_ptr<GsmSMSClient>(gsm_sms_client)); - - SetImageBurnerClient( - scoped_ptr<ImageBurnerClient>(new FakeImageBurnerClient)); - SetIntrospectableClient( - scoped_ptr<IntrospectableClient>(new FakeIntrospectableClient)); - SetModemMessagingClient( - scoped_ptr<ModemMessagingClient>(new FakeModemMessagingClient)); - SetNfcAdapterClient(scoped_ptr<NfcAdapterClient>(new FakeNfcAdapterClient)); - SetNfcDeviceClient(scoped_ptr<NfcDeviceClient>(new FakeNfcDeviceClient)); - SetNfcManagerClient(scoped_ptr<NfcManagerClient>(new FakeNfcManagerClient)); - SetNfcRecordClient(scoped_ptr<NfcRecordClient>(new FakeNfcRecordClient)); - SetNfcTagClient(scoped_ptr<NfcTagClient>(new FakeNfcTagClient)); - SetPermissionBrokerClient( - scoped_ptr<PermissionBrokerClient>(new FakePermissionBrokerClient)); - SetPowerManagerClient( - scoped_ptr<PowerManagerClient>(PowerManagerClient::Create(client_type))); - SetSessionManagerClient(scoped_ptr<SessionManagerClient>( - SessionManagerClient::Create(client_type))); - SetSMSClient(scoped_ptr<SMSClient>(new FakeSMSClient)); - SetSystemClockClient( - scoped_ptr<SystemClockClient>(new FakeSystemClockClient)); - SetUpdateEngineClient( - scoped_ptr<UpdateEngineClient>(UpdateEngineClient::Create(client_type))); - - SetPowerPolicyController(make_scoped_ptr(new PowerPolicyController)); -} - -void FakeDBusThreadManager::SetFakeShillClients() { - SetShillManagerClient( - scoped_ptr<ShillManagerClient>(new FakeShillManagerClient)); - SetShillDeviceClient( - scoped_ptr<ShillDeviceClient>(new FakeShillDeviceClient)); - SetShillIPConfigClient( - scoped_ptr<ShillIPConfigClient>(new FakeShillIPConfigClient)); - SetShillServiceClient( - scoped_ptr<ShillServiceClient>(new FakeShillServiceClient)); - SetShillProfileClient( - scoped_ptr<ShillProfileClient>(new FakeShillProfileClient)); -} - -void FakeDBusThreadManager::SetupDefaultEnvironment() { - ShillManagerClient::TestInterface* manager = - shill_manager_client_->GetTestInterface(); - if (manager) - manager->SetupDefaultEnvironment(); -} - -void FakeDBusThreadManager::SetBluetoothAdapterClient( - scoped_ptr<BluetoothAdapterClient> client) { - bluetooth_adapter_client_ = client.Pass(); -} - -void FakeDBusThreadManager::SetBluetoothAgentManagerClient( - scoped_ptr<BluetoothAgentManagerClient> client) { - bluetooth_agent_manager_client_ = client.Pass(); -} - -void FakeDBusThreadManager::SetBluetoothDeviceClient( - scoped_ptr<BluetoothDeviceClient> client) { - bluetooth_device_client_ = client.Pass(); -} - -void FakeDBusThreadManager::SetBluetoothGattCharacteristicClient( - scoped_ptr<BluetoothGattCharacteristicClient> client) { - bluetooth_gatt_characteristic_client_ = client.Pass(); -} - -void FakeDBusThreadManager::SetBluetoothGattDescriptorClient( - scoped_ptr<BluetoothGattDescriptorClient> client) { - bluetooth_gatt_descriptor_client_ = client.Pass(); -} - -void FakeDBusThreadManager::SetBluetoothGattManagerClient( - scoped_ptr<BluetoothGattManagerClient> client) { - bluetooth_gatt_manager_client_ = client.Pass(); -} - -void FakeDBusThreadManager::SetBluetoothGattServiceClient( - scoped_ptr<BluetoothGattServiceClient> client) { - bluetooth_gatt_service_client_ = client.Pass(); -} - -void FakeDBusThreadManager::SetBluetoothInputClient( - scoped_ptr<BluetoothInputClient> client) { - bluetooth_input_client_ = client.Pass(); -} - -void FakeDBusThreadManager::SetBluetoothProfileManagerClient( - scoped_ptr<BluetoothProfileManagerClient> client) { - bluetooth_profile_manager_client_ = client.Pass(); -} - -void FakeDBusThreadManager::SetCrasAudioClient( - scoped_ptr<CrasAudioClient> client) { - cras_audio_client_ = client.Pass(); -} - -void FakeDBusThreadManager::SetCrosDisksClient( - scoped_ptr<CrosDisksClient> client) { - cros_disks_client_ = client.Pass(); -} - -void FakeDBusThreadManager::SetCryptohomeClient( - scoped_ptr<CryptohomeClient> client) { - cryptohome_client_ = client.Pass(); -} - -void FakeDBusThreadManager::SetDebugDaemonClient( - scoped_ptr<DebugDaemonClient> client) { - debug_daemon_client_ = client.Pass(); -} - -void FakeDBusThreadManager::SetEasyUnlockClient( - scoped_ptr<EasyUnlockClient> client) { - easy_unlock_client_ = client.Pass(); -} - -void FakeDBusThreadManager::SetLorgnetteManagerClient( - scoped_ptr<LorgnetteManagerClient> client) { - lorgnette_manager_client_ = client.Pass(); -} - -void FakeDBusThreadManager::SetShillDeviceClient( - scoped_ptr<ShillDeviceClient> client) { - shill_device_client_ = client.Pass(); -} - -void FakeDBusThreadManager::SetShillIPConfigClient( - scoped_ptr<ShillIPConfigClient> client) { - shill_ipconfig_client_ = client.Pass(); -} - -void FakeDBusThreadManager::SetShillManagerClient( - scoped_ptr<ShillManagerClient> client) { - shill_manager_client_ = client.Pass(); -} - -void FakeDBusThreadManager::SetShillServiceClient( - scoped_ptr<ShillServiceClient> client) { - shill_service_client_ = client.Pass(); -} - -void FakeDBusThreadManager::SetShillProfileClient( - scoped_ptr<ShillProfileClient> client) { - shill_profile_client_ = client.Pass(); -} - -void FakeDBusThreadManager::SetGsmSMSClient(scoped_ptr<GsmSMSClient> client) { - gsm_sms_client_ = client.Pass(); -} - -void FakeDBusThreadManager::SetImageBurnerClient( - scoped_ptr<ImageBurnerClient> client) { - image_burner_client_ = client.Pass(); -} - -void FakeDBusThreadManager::SetIntrospectableClient( - scoped_ptr<IntrospectableClient> client) { - introspectable_client_ = client.Pass(); -} - -void FakeDBusThreadManager::SetModemMessagingClient( - scoped_ptr<ModemMessagingClient> client) { - modem_messaging_client_ = client.Pass(); -} - -void FakeDBusThreadManager::SetNfcAdapterClient( - scoped_ptr<NfcAdapterClient> client) { - nfc_adapter_client_ = client.Pass(); -} - -void FakeDBusThreadManager::SetNfcDeviceClient( - scoped_ptr<NfcDeviceClient> client) { - nfc_device_client_ = client.Pass(); -} - -void FakeDBusThreadManager::SetNfcManagerClient( - scoped_ptr<NfcManagerClient> client) { - nfc_manager_client_ = client.Pass(); -} - -void FakeDBusThreadManager::SetNfcRecordClient( - scoped_ptr<NfcRecordClient> client) { - nfc_record_client_ = client.Pass(); -} - -void FakeDBusThreadManager::SetNfcTagClient(scoped_ptr<NfcTagClient> client) { - nfc_tag_client_ = client.Pass(); -} - -void FakeDBusThreadManager::SetPermissionBrokerClient( - scoped_ptr<PermissionBrokerClient> client) { - permission_broker_client_ = client.Pass(); -} - -void FakeDBusThreadManager::SetPowerManagerClient( - scoped_ptr<PowerManagerClient> client) { - power_manager_client_ = client.Pass(); -} - -void FakeDBusThreadManager::SetPowerPolicyController( - scoped_ptr<PowerPolicyController> client) { - power_policy_controller_ = client.Pass(); -} - -void FakeDBusThreadManager::SetSessionManagerClient( - scoped_ptr<SessionManagerClient> client) { - session_manager_client_ = client.Pass(); -} - -void FakeDBusThreadManager::SetSMSClient(scoped_ptr<SMSClient> client) { - sms_client_ = client.Pass(); -} - -void FakeDBusThreadManager::SetSystemClockClient( - scoped_ptr<SystemClockClient> client) { - system_clock_client_ = client.Pass(); -} - -void FakeDBusThreadManager::SetUpdateEngineClient( - scoped_ptr<UpdateEngineClient> client) { - update_engine_client_ = client.Pass(); -} - -dbus::Bus* FakeDBusThreadManager::GetSystemBus() { - return NULL; -} - -BluetoothAdapterClient* FakeDBusThreadManager::GetBluetoothAdapterClient() { - return bluetooth_adapter_client_.get(); -} - -BluetoothAgentManagerClient* -FakeDBusThreadManager::GetBluetoothAgentManagerClient() { - return bluetooth_agent_manager_client_.get(); -} - -BluetoothDeviceClient* FakeDBusThreadManager::GetBluetoothDeviceClient() { - return bluetooth_device_client_.get(); -} - -BluetoothGattCharacteristicClient* -FakeDBusThreadManager::GetBluetoothGattCharacteristicClient() { - return bluetooth_gatt_characteristic_client_.get(); -} - -BluetoothGattDescriptorClient* -FakeDBusThreadManager::GetBluetoothGattDescriptorClient() { - return bluetooth_gatt_descriptor_client_.get(); -} - -BluetoothGattManagerClient* -FakeDBusThreadManager::GetBluetoothGattManagerClient() { - return bluetooth_gatt_manager_client_.get(); -} - -BluetoothGattServiceClient* -FakeDBusThreadManager::GetBluetoothGattServiceClient() { - return bluetooth_gatt_service_client_.get(); -} - -BluetoothInputClient* FakeDBusThreadManager::GetBluetoothInputClient() { - return bluetooth_input_client_.get(); -} - -BluetoothProfileManagerClient* -FakeDBusThreadManager::GetBluetoothProfileManagerClient() { - return bluetooth_profile_manager_client_.get(); -} - -CrasAudioClient* FakeDBusThreadManager::GetCrasAudioClient() { - return cras_audio_client_.get(); -} - -CrosDisksClient* FakeDBusThreadManager::GetCrosDisksClient() { - return cros_disks_client_.get(); -} - -CryptohomeClient* FakeDBusThreadManager::GetCryptohomeClient() { - return cryptohome_client_.get(); -} - -DebugDaemonClient* FakeDBusThreadManager::GetDebugDaemonClient() { - return debug_daemon_client_.get(); -} - -EasyUnlockClient* FakeDBusThreadManager::GetEasyUnlockClient() { - return easy_unlock_client_.get(); -} -LorgnetteManagerClient* FakeDBusThreadManager::GetLorgnetteManagerClient() { - return lorgnette_manager_client_.get(); -} - -ShillDeviceClient* FakeDBusThreadManager::GetShillDeviceClient() { - return shill_device_client_.get(); -} - -ShillIPConfigClient* FakeDBusThreadManager::GetShillIPConfigClient() { - return shill_ipconfig_client_.get(); -} - -ShillManagerClient* FakeDBusThreadManager::GetShillManagerClient() { - return shill_manager_client_.get(); -} - -ShillProfileClient* FakeDBusThreadManager::GetShillProfileClient() { - return shill_profile_client_.get(); -} - -ShillServiceClient* FakeDBusThreadManager::GetShillServiceClient() { - return shill_service_client_.get(); -} - -GsmSMSClient* FakeDBusThreadManager::GetGsmSMSClient() { - return gsm_sms_client_.get(); -} - -ImageBurnerClient* FakeDBusThreadManager::GetImageBurnerClient() { - return image_burner_client_.get(); -} - -IntrospectableClient* FakeDBusThreadManager::GetIntrospectableClient() { - return introspectable_client_.get(); -} - -ModemMessagingClient* FakeDBusThreadManager::GetModemMessagingClient() { - return modem_messaging_client_.get(); -} - -NfcAdapterClient* FakeDBusThreadManager::GetNfcAdapterClient() { - return nfc_adapter_client_.get(); -} - -NfcDeviceClient* FakeDBusThreadManager::GetNfcDeviceClient() { - return nfc_device_client_.get(); -} - -NfcManagerClient* FakeDBusThreadManager::GetNfcManagerClient() { - return nfc_manager_client_.get(); -} - -NfcTagClient* FakeDBusThreadManager::GetNfcTagClient() { - return nfc_tag_client_.get(); -} - -NfcRecordClient* FakeDBusThreadManager::GetNfcRecordClient() { - return nfc_record_client_.get(); -} - -PermissionBrokerClient* FakeDBusThreadManager::GetPermissionBrokerClient() { - return permission_broker_client_.get(); -} - -PowerManagerClient* FakeDBusThreadManager::GetPowerManagerClient() { - return power_manager_client_.get(); -} - -PowerPolicyController* FakeDBusThreadManager::GetPowerPolicyController() { - return power_policy_controller_.get(); -} - -SessionManagerClient* FakeDBusThreadManager::GetSessionManagerClient() { - return session_manager_client_.get(); -} - -SMSClient* FakeDBusThreadManager::GetSMSClient() { - return sms_client_.get(); -} - -SystemClockClient* FakeDBusThreadManager::GetSystemClockClient() { - return system_clock_client_.get(); -} - -UpdateEngineClient* FakeDBusThreadManager::GetUpdateEngineClient() { - return update_engine_client_.get(); -} - -} // namespace chromeos diff --git a/chromeos/dbus/fake_dbus_thread_manager.h b/chromeos/dbus/fake_dbus_thread_manager.h deleted file mode 100644 index d70f599..0000000 --- a/chromeos/dbus/fake_dbus_thread_manager.h +++ /dev/null @@ -1,167 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROMEOS_DBUS_FAKE_DBUS_THREAD_MANAGER_H_ -#define CHROMEOS_DBUS_FAKE_DBUS_THREAD_MANAGER_H_ - -#include "base/logging.h" -#include "chromeos/chromeos_export.h" -#include "chromeos/dbus/dbus_thread_manager.h" - -namespace dbus { -class Bus; -class ObjectPath; -} // namespace dbus - -namespace chromeos { - -// This class provides a fake implementation of DBusThreadManager, which -// hosts fake D-Bus clients. -class CHROMEOS_EXPORT FakeDBusThreadManager : public DBusThreadManager { - public: - FakeDBusThreadManager(); - virtual ~FakeDBusThreadManager(); - - // Creates and sets all fake DBusClients and the PowerPolicyController. - void SetFakeClients(); - - // Creates and sets all fake Shill DBusClients. - void SetFakeShillClients(); - - // Sets up any default environment for fake clients, e.g. for UI testing. - void SetupDefaultEnvironment(); - - void SetBluetoothAdapterClient(scoped_ptr<BluetoothAdapterClient> client); - void SetBluetoothAgentManagerClient( - scoped_ptr<BluetoothAgentManagerClient> client); - void SetBluetoothDeviceClient(scoped_ptr<BluetoothDeviceClient> client); - void SetBluetoothGattCharacteristicClient( - scoped_ptr<BluetoothGattCharacteristicClient> client); - void SetBluetoothGattDescriptorClient( - scoped_ptr<BluetoothGattDescriptorClient> client); - void SetBluetoothGattManagerClient( - scoped_ptr<BluetoothGattManagerClient> client); - void SetBluetoothGattServiceClient( - scoped_ptr<BluetoothGattServiceClient> client); - void SetBluetoothInputClient(scoped_ptr<BluetoothInputClient> client); - void SetBluetoothProfileManagerClient( - scoped_ptr<BluetoothProfileManagerClient> client); - void SetCrasAudioClient(scoped_ptr<CrasAudioClient> client); - void SetCrosDisksClient(scoped_ptr<CrosDisksClient> client); - void SetCryptohomeClient(scoped_ptr<CryptohomeClient> client); - void SetDebugDaemonClient(scoped_ptr<DebugDaemonClient> client); - void SetEasyUnlockClient(scoped_ptr<EasyUnlockClient> client); - void SetLorgnetteManagerClient(scoped_ptr<LorgnetteManagerClient> client); - void SetShillDeviceClient(scoped_ptr<ShillDeviceClient> client); - void SetShillIPConfigClient(scoped_ptr<ShillIPConfigClient> client); - void SetShillManagerClient(scoped_ptr<ShillManagerClient> client); - void SetShillServiceClient(scoped_ptr<ShillServiceClient> client); - void SetShillProfileClient(scoped_ptr<ShillProfileClient> client); - void SetGsmSMSClient(scoped_ptr<GsmSMSClient> client); - void SetImageBurnerClient(scoped_ptr<ImageBurnerClient> client); - void SetIntrospectableClient(scoped_ptr<IntrospectableClient> client); - void SetModemMessagingClient(scoped_ptr<ModemMessagingClient> client); - void SetNfcAdapterClient(scoped_ptr<NfcAdapterClient> client); - void SetNfcDeviceClient(scoped_ptr<NfcDeviceClient> client); - void SetNfcManagerClient(scoped_ptr<NfcManagerClient> client); - void SetNfcRecordClient(scoped_ptr<NfcRecordClient> client); - void SetNfcTagClient(scoped_ptr<NfcTagClient> client); - void SetPermissionBrokerClient(scoped_ptr<PermissionBrokerClient> client); - void SetPowerManagerClient(scoped_ptr<PowerManagerClient> client); - void SetPowerPolicyController(scoped_ptr<PowerPolicyController> client); - void SetSessionManagerClient(scoped_ptr<SessionManagerClient> client); - void SetSMSClient(scoped_ptr<SMSClient> client); - void SetSystemClockClient(scoped_ptr<SystemClockClient> client); - void SetUpdateEngineClient(scoped_ptr<UpdateEngineClient> client); - - virtual dbus::Bus* GetSystemBus() OVERRIDE; - - virtual BluetoothAdapterClient* GetBluetoothAdapterClient() OVERRIDE; - virtual BluetoothAgentManagerClient* - GetBluetoothAgentManagerClient() OVERRIDE; - virtual BluetoothDeviceClient* GetBluetoothDeviceClient() OVERRIDE; - virtual BluetoothGattCharacteristicClient* - GetBluetoothGattCharacteristicClient() OVERRIDE; - virtual BluetoothGattDescriptorClient* - GetBluetoothGattDescriptorClient() OVERRIDE; - virtual BluetoothGattManagerClient* GetBluetoothGattManagerClient() OVERRIDE; - virtual BluetoothGattServiceClient* GetBluetoothGattServiceClient() OVERRIDE; - virtual BluetoothInputClient* GetBluetoothInputClient() OVERRIDE; - virtual BluetoothProfileManagerClient* - GetBluetoothProfileManagerClient() OVERRIDE; - virtual CrasAudioClient* GetCrasAudioClient() OVERRIDE; - virtual CrosDisksClient* GetCrosDisksClient() OVERRIDE; - virtual CryptohomeClient* GetCryptohomeClient() OVERRIDE; - virtual DebugDaemonClient* GetDebugDaemonClient() OVERRIDE; - virtual EasyUnlockClient* GetEasyUnlockClient() OVERRIDE; - virtual LorgnetteManagerClient* GetLorgnetteManagerClient() OVERRIDE; - virtual ShillDeviceClient* GetShillDeviceClient() OVERRIDE; - virtual ShillIPConfigClient* GetShillIPConfigClient() OVERRIDE; - virtual ShillManagerClient* GetShillManagerClient() OVERRIDE; - virtual ShillProfileClient* GetShillProfileClient() OVERRIDE; - virtual ShillServiceClient* GetShillServiceClient() OVERRIDE; - virtual GsmSMSClient* GetGsmSMSClient() OVERRIDE; - virtual ImageBurnerClient* GetImageBurnerClient() OVERRIDE; - virtual IntrospectableClient* GetIntrospectableClient() OVERRIDE; - virtual ModemMessagingClient* GetModemMessagingClient() OVERRIDE; - virtual NfcAdapterClient* GetNfcAdapterClient() OVERRIDE; - virtual NfcDeviceClient* GetNfcDeviceClient() OVERRIDE; - virtual NfcManagerClient* GetNfcManagerClient() OVERRIDE; - virtual NfcRecordClient* GetNfcRecordClient() OVERRIDE; - virtual NfcTagClient* GetNfcTagClient() OVERRIDE; - virtual PermissionBrokerClient* GetPermissionBrokerClient() OVERRIDE; - virtual PowerManagerClient* GetPowerManagerClient() OVERRIDE; - virtual PowerPolicyController* GetPowerPolicyController() OVERRIDE; - virtual SessionManagerClient* GetSessionManagerClient() OVERRIDE; - virtual SMSClient* GetSMSClient() OVERRIDE; - virtual SystemClockClient* GetSystemClockClient() OVERRIDE; - virtual UpdateEngineClient* GetUpdateEngineClient() OVERRIDE; - - private: - scoped_ptr<BluetoothAdapterClient> bluetooth_adapter_client_; - scoped_ptr<BluetoothAgentManagerClient> bluetooth_agent_manager_client_; - scoped_ptr<BluetoothDeviceClient> bluetooth_device_client_; - scoped_ptr<BluetoothGattCharacteristicClient> - bluetooth_gatt_characteristic_client_; - scoped_ptr<BluetoothGattDescriptorClient> - bluetooth_gatt_descriptor_client_; - scoped_ptr<BluetoothGattManagerClient> bluetooth_gatt_manager_client_; - scoped_ptr<BluetoothGattServiceClient> bluetooth_gatt_service_client_; - scoped_ptr<BluetoothInputClient> bluetooth_input_client_; - scoped_ptr<BluetoothProfileManagerClient> bluetooth_profile_manager_client_; - scoped_ptr<CrasAudioClient> cras_audio_client_; - scoped_ptr<CrosDisksClient> cros_disks_client_; - scoped_ptr<CryptohomeClient> cryptohome_client_; - scoped_ptr<DebugDaemonClient> debug_daemon_client_; - scoped_ptr<EasyUnlockClient> easy_unlock_client_; - scoped_ptr<LorgnetteManagerClient> lorgnette_manager_client_; - scoped_ptr<ShillDeviceClient> shill_device_client_; - scoped_ptr<ShillIPConfigClient> shill_ipconfig_client_; - scoped_ptr<ShillManagerClient> shill_manager_client_; - scoped_ptr<ShillServiceClient> shill_service_client_; - scoped_ptr<ShillProfileClient> shill_profile_client_; - scoped_ptr<GsmSMSClient> gsm_sms_client_; - scoped_ptr<ImageBurnerClient> image_burner_client_; - scoped_ptr<IntrospectableClient> introspectable_client_; - scoped_ptr<ModemMessagingClient> modem_messaging_client_; - scoped_ptr<NfcAdapterClient> nfc_adapter_client_; - scoped_ptr<NfcDeviceClient> nfc_device_client_; - scoped_ptr<NfcManagerClient> nfc_manager_client_; - scoped_ptr<NfcRecordClient> nfc_record_client_; - scoped_ptr<NfcTagClient> nfc_tag_client_; - scoped_ptr<PermissionBrokerClient> permission_broker_client_; - scoped_ptr<SystemClockClient> system_clock_client_; - scoped_ptr<PowerManagerClient> power_manager_client_; - scoped_ptr<SessionManagerClient> session_manager_client_; - scoped_ptr<SMSClient> sms_client_; - scoped_ptr<UpdateEngineClient> update_engine_client_; - - scoped_ptr<PowerPolicyController> power_policy_controller_; - - DISALLOW_COPY_AND_ASSIGN(FakeDBusThreadManager); -}; - -} // namespace chromeos - -#endif // CHROMEOS_DBUS_FAKE_DBUS_THREAD_MANAGER_H_ diff --git a/chromeos/dbus/fake_shill_manager_client.cc b/chromeos/dbus/fake_shill_manager_client.cc index f524c1f..7b4eb61 100644 --- a/chromeos/dbus/fake_shill_manager_client.cc +++ b/chromeos/dbus/fake_shill_manager_client.cc @@ -565,6 +565,11 @@ void FakeShillManagerClient::SetBestServiceToConnect( } void FakeShillManagerClient::SetupDefaultEnvironment() { + // Bail out from setup if there is no message loop. This will be the common + // case for tests that are not testing Shill. + if (!base::MessageLoop::current()) + return; + DBusThreadManager* dbus_manager = DBusThreadManager::Get(); ShillServiceClient::TestInterface* services = dbus_manager->GetShillServiceClient()->GetTestInterface(); diff --git a/chromeos/dbus/power_policy_controller_unittest.cc b/chromeos/dbus/power_policy_controller_unittest.cc index b4e7bf4..755cc53 100644 --- a/chromeos/dbus/power_policy_controller_unittest.cc +++ b/chromeos/dbus/power_policy_controller_unittest.cc @@ -5,8 +5,8 @@ #include "chromeos/dbus/power_policy_controller.h" #include "base/memory/scoped_ptr.h" +#include "base/message_loop/message_loop.h" #include "chromeos/dbus/dbus_thread_manager.h" -#include "chromeos/dbus/fake_dbus_thread_manager.h" #include "chromeos/dbus/fake_power_manager_client.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" @@ -22,14 +22,14 @@ class PowerPolicyControllerTest : public testing::Test { virtual ~PowerPolicyControllerTest() {} virtual void SetUp() OVERRIDE { - dbus_manager_ = new FakeDBusThreadManager; + scoped_ptr<DBusThreadManagerSetter> dbus_setter = + chromeos::DBusThreadManager::GetSetterForTesting(); fake_power_client_ = new FakePowerManagerClient; - dbus_manager_->SetPowerManagerClient( + dbus_setter->SetPowerManagerClient( scoped_ptr<PowerManagerClient>(fake_power_client_)); - DBusThreadManager::InitializeForTesting(dbus_manager_); // Takes ownership. policy_controller_.reset(new PowerPolicyController); - policy_controller_->Init(dbus_manager_); + policy_controller_->Init(DBusThreadManager::Get()); } virtual void TearDown() OVERRIDE { @@ -38,9 +38,9 @@ class PowerPolicyControllerTest : public testing::Test { } protected: - FakeDBusThreadManager* dbus_manager_; // Not owned. FakePowerManagerClient* fake_power_client_; scoped_ptr<PowerPolicyController> policy_controller_; + base::MessageLoop message_loop_; }; TEST_F(PowerPolicyControllerTest, Prefs) { diff --git a/chromeos/disks/disk_mount_manager_unittest.cc b/chromeos/disks/disk_mount_manager_unittest.cc index b7a8e49..674ee7a 100644 --- a/chromeos/disks/disk_mount_manager_unittest.cc +++ b/chromeos/disks/disk_mount_manager_unittest.cc @@ -4,8 +4,8 @@ #include "base/bind.h" #include "base/message_loop/message_loop.h" +#include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/dbus/fake_cros_disks_client.h" -#include "chromeos/dbus/fake_dbus_thread_manager.h" #include "chromeos/disks/disk_mount_manager.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" @@ -14,7 +14,6 @@ using chromeos::disks::DiskMountManager; using chromeos::CrosDisksClient; using chromeos::DBusThreadManager; using chromeos::FakeCrosDisksClient; -using chromeos::FakeDBusThreadManager; using testing::_; using testing::Field; using testing::InSequence; @@ -123,13 +122,10 @@ class DiskMountManagerTest : public testing::Test { // Initializes disk mount manager disks and mount points. // Adds a test observer to the disk mount manager. virtual void SetUp() { - FakeDBusThreadManager* fake_thread_manager = new FakeDBusThreadManager(); fake_cros_disks_client_ = new FakeCrosDisksClient; - fake_thread_manager->SetCrosDisksClient( + DBusThreadManager::GetSetterForTesting()->SetCrosDisksClient( scoped_ptr<CrosDisksClient>(fake_cros_disks_client_)); - DBusThreadManager::InitializeForTesting(fake_thread_manager); - DiskMountManager::Initialize(); InitDisksAndMountPoints(); diff --git a/chromeos/network/client_cert_resolver_unittest.cc b/chromeos/network/client_cert_resolver_unittest.cc index f2dc452..89df842 100644 --- a/chromeos/network/client_cert_resolver_unittest.cc +++ b/chromeos/network/client_cert_resolver_unittest.cc @@ -69,7 +69,7 @@ class ClientCertResolverTest : public testing::Test { base::Callback<void(crypto::ScopedPK11Slot)>()))); test_nssdb_->SetSlowTaskRunnerForTest(message_loop_.message_loop_proxy()); - DBusThreadManager::InitializeWithStub(); + DBusThreadManager::Initialize(); service_test_ = DBusThreadManager::Get()->GetShillServiceClient()->GetTestInterface(); profile_test_ = diff --git a/chromeos/network/geolocation_handler_unittest.cc b/chromeos/network/geolocation_handler_unittest.cc index be0985d..af5dc19 100644 --- a/chromeos/network/geolocation_handler_unittest.cc +++ b/chromeos/network/geolocation_handler_unittest.cc @@ -24,7 +24,7 @@ class GeolocationHandlerTest : public testing::Test { virtual void SetUp() OVERRIDE { // Initialize DBusThreadManager with a stub implementation. - DBusThreadManager::InitializeWithStub(); + DBusThreadManager::Initialize(); // Get the test interface for manager / device. manager_test_ = DBusThreadManager::Get()->GetShillManagerClient()->GetTestInterface(); diff --git a/chromeos/network/host_resolver_impl_chromeos_unittest.cc b/chromeos/network/host_resolver_impl_chromeos_unittest.cc index e27175ed..9567b8b 100644 --- a/chromeos/network/host_resolver_impl_chromeos_unittest.cc +++ b/chromeos/network/host_resolver_impl_chromeos_unittest.cc @@ -41,7 +41,7 @@ class HostResolverImplChromeOSTest : public testing::Test { virtual ~HostResolverImplChromeOSTest() {} virtual void SetUp() OVERRIDE { - chromeos::DBusThreadManager::InitializeWithStub(); + chromeos::DBusThreadManager::Initialize(); network_state_handler_.reset( chromeos::NetworkStateHandler::InitializeForTest()); diff --git a/chromeos/network/managed_network_configuration_handler_unittest.cc b/chromeos/network/managed_network_configuration_handler_unittest.cc index c3cc5c4..b4ec1cc 100644 --- a/chromeos/network/managed_network_configuration_handler_unittest.cc +++ b/chromeos/network/managed_network_configuration_handler_unittest.cc @@ -12,7 +12,6 @@ #include "base/stl_util.h" #include "base/values.h" #include "chromeos/dbus/dbus_thread_manager.h" -#include "chromeos/dbus/fake_dbus_thread_manager.h" #include "chromeos/dbus/mock_shill_manager_client.h" #include "chromeos/dbus/mock_shill_profile_client.h" #include "chromeos/dbus/shill_client_helper.h" @@ -159,16 +158,15 @@ class ManagedNetworkConfigurationHandlerTest : public testing::Test { } virtual void SetUp() OVERRIDE { - FakeDBusThreadManager* dbus_thread_manager = new FakeDBusThreadManager; + scoped_ptr<DBusThreadManagerSetter> dbus_setter = + DBusThreadManager::GetSetterForTesting(); mock_manager_client_ = new StrictMock<MockShillManagerClient>(); mock_profile_client_ = new StrictMock<MockShillProfileClient>(); - dbus_thread_manager->SetShillManagerClient( + dbus_setter->SetShillManagerClient( scoped_ptr<ShillManagerClient>(mock_manager_client_).Pass()); - dbus_thread_manager->SetShillProfileClient( + dbus_setter->SetShillProfileClient( scoped_ptr<ShillProfileClient>(mock_profile_client_).Pass()); - DBusThreadManager::InitializeForTesting(dbus_thread_manager); - SetNetworkConfigurationHandlerExpectations(); ON_CALL(*mock_profile_client_, GetProperties(_,_,_)) diff --git a/chromeos/network/network_cert_migrator_unittest.cc b/chromeos/network/network_cert_migrator_unittest.cc index 32798c8..a749cd9 100644 --- a/chromeos/network/network_cert_migrator_unittest.cc +++ b/chromeos/network/network_cert_migrator_unittest.cc @@ -58,7 +58,7 @@ class NetworkCertMigratorTest : public testing::Test { base::Callback<void(crypto::ScopedPK11Slot)>()))); test_nssdb_->SetSlowTaskRunnerForTest(message_loop_.message_loop_proxy()); - DBusThreadManager::InitializeWithStub(); + DBusThreadManager::Initialize(); service_test_ = DBusThreadManager::Get()->GetShillServiceClient()->GetTestInterface(); DBusThreadManager::Get() diff --git a/chromeos/network/network_configuration_handler_unittest.cc b/chromeos/network/network_configuration_handler_unittest.cc index dcc47f0..3609b11 100644 --- a/chromeos/network/network_configuration_handler_unittest.cc +++ b/chromeos/network/network_configuration_handler_unittest.cc @@ -8,7 +8,6 @@ #include "base/strings/string_piece.h" #include "base/values.h" #include "chromeos/dbus/dbus_thread_manager.h" -#include "chromeos/dbus/fake_dbus_thread_manager.h" #include "chromeos/dbus/mock_shill_manager_client.h" #include "chromeos/dbus/mock_shill_profile_client.h" #include "chromeos/dbus/mock_shill_service_client.h" @@ -99,15 +98,16 @@ class NetworkConfigurationHandlerTest : public testing::Test { virtual ~NetworkConfigurationHandlerTest() {} virtual void SetUp() OVERRIDE { - FakeDBusThreadManager* dbus_thread_manager = new FakeDBusThreadManager; + scoped_ptr<DBusThreadManagerSetter> dbus_setter = + DBusThreadManager::GetSetterForTesting(); mock_manager_client_ = new MockShillManagerClient(); mock_profile_client_ = new MockShillProfileClient(); mock_service_client_ = new MockShillServiceClient(); - dbus_thread_manager->SetShillManagerClient( + dbus_setter->SetShillManagerClient( scoped_ptr<ShillManagerClient>(mock_manager_client_).Pass()); - dbus_thread_manager->SetShillProfileClient( + dbus_setter->SetShillProfileClient( scoped_ptr<ShillProfileClient>(mock_profile_client_).Pass()); - dbus_thread_manager->SetShillServiceClient( + dbus_setter->SetShillServiceClient( scoped_ptr<ShillServiceClient>(mock_service_client_).Pass()); EXPECT_CALL(*mock_service_client_, GetProperties(_, _)) @@ -119,8 +119,6 @@ class NetworkConfigurationHandlerTest : public testing::Test { EXPECT_CALL(*mock_manager_client_, RemovePropertyChangedObserver(_)) .Times(AnyNumber()); - DBusThreadManager::InitializeForTesting(dbus_thread_manager); - network_state_handler_.reset(NetworkStateHandler::InitializeForTest()); network_configuration_handler_.reset(new NetworkConfigurationHandler()); network_configuration_handler_->Init(network_state_handler_.get()); @@ -436,7 +434,7 @@ class NetworkConfigurationHandlerStubTest : public testing::Test { } virtual void SetUp() OVERRIDE { - DBusThreadManager::InitializeWithStub(); + DBusThreadManager::Initialize(); network_state_handler_.reset(NetworkStateHandler::InitializeForTest()); test_observer_.reset(new TestObserver()); diff --git a/chromeos/network/network_connection_handler_unittest.cc b/chromeos/network/network_connection_handler_unittest.cc index b22c07d..ed737ac 100644 --- a/chromeos/network/network_connection_handler_unittest.cc +++ b/chromeos/network/network_connection_handler_unittest.cc @@ -13,7 +13,7 @@ #include "base/run_loop.h" #include "base/strings/stringprintf.h" #include "chromeos/cert_loader.h" -#include "chromeos/dbus/fake_dbus_thread_manager.h" +#include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/dbus/shill_device_client.h" #include "chromeos/dbus/shill_manager_client.h" #include "chromeos/dbus/shill_profile_client.h" @@ -77,9 +77,8 @@ class NetworkConnectionHandlerTest : public testing::Test { CertLoader* cert_loader = CertLoader::Get(); cert_loader->force_hardware_backed_for_test(); - FakeDBusThreadManager* dbus_manager = new FakeDBusThreadManager; - dbus_manager->SetFakeClients(); - DBusThreadManager::InitializeForTesting(dbus_manager); + DBusThreadManager::Initialize(); + DBusThreadManager* dbus_manager = DBusThreadManager::Get(); test_manager_client_ = dbus_manager->GetShillManagerClient()->GetTestInterface(); test_service_client_ = diff --git a/chromeos/network/network_device_handler_unittest.cc b/chromeos/network/network_device_handler_unittest.cc index af4b93f..644ac57 100644 --- a/chromeos/network/network_device_handler_unittest.cc +++ b/chromeos/network/network_device_handler_unittest.cc @@ -6,7 +6,7 @@ #include "base/memory/scoped_ptr.h" #include "base/message_loop/message_loop.h" #include "base/values.h" -#include "chromeos/dbus/fake_dbus_thread_manager.h" +#include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/dbus/fake_shill_device_client.h" #include "chromeos/dbus/fake_shill_manager_client.h" #include "chromeos/network/network_device_handler_impl.h" @@ -32,13 +32,9 @@ class NetworkDeviceHandlerTest : public testing::Test { virtual ~NetworkDeviceHandlerTest() {} virtual void SetUp() OVERRIDE { - FakeDBusThreadManager* dbus_manager = new FakeDBusThreadManager; - dbus_manager->SetFakeShillClients(); - fake_device_client_ = new FakeShillDeviceClient; - dbus_manager->SetShillDeviceClient( + DBusThreadManager::GetSetterForTesting()->SetShillDeviceClient( scoped_ptr<ShillDeviceClient>(fake_device_client_)); - DBusThreadManager::InitializeForTesting(dbus_manager); success_callback_ = base::Bind(&NetworkDeviceHandlerTest::SuccessCallback, base::Unretained(this)); diff --git a/chromeos/network/network_sms_handler_unittest.cc b/chromeos/network/network_sms_handler_unittest.cc index b1c06e1..a050d2b 100644 --- a/chromeos/network/network_sms_handler_unittest.cc +++ b/chromeos/network/network_sms_handler_unittest.cc @@ -60,7 +60,7 @@ class NetworkSmsHandlerTest : public testing::Test { command_line->AppendSwitch(chromeos::switches::kSmsTestMessages); // Initialize DBusThreadManager with a stub implementation. - DBusThreadManager::InitializeWithStub(); + DBusThreadManager::Initialize(); ShillDeviceClient::TestInterface* device_test = DBusThreadManager::Get()->GetShillDeviceClient()->GetTestInterface(); ASSERT_TRUE(device_test); diff --git a/chromeos/network/network_state_handler_unittest.cc b/chromeos/network/network_state_handler_unittest.cc index 74c9b6d..6b41251 100644 --- a/chromeos/network/network_state_handler_unittest.cc +++ b/chromeos/network/network_state_handler_unittest.cc @@ -179,7 +179,7 @@ class NetworkStateHandlerTest : public testing::Test { virtual void SetUp() OVERRIDE { // Initialize DBusThreadManager with a stub implementation. - DBusThreadManager::InitializeWithStub(); + DBusThreadManager::Initialize(); SetupDefaultShillState(); network_state_handler_.reset(new NetworkStateHandler); test_observer_.reset(new TestObserver(network_state_handler_.get())); diff --git a/chromeos/network/shill_property_handler_unittest.cc b/chromeos/network/shill_property_handler_unittest.cc index cb82890..6c311ea 100644 --- a/chromeos/network/shill_property_handler_unittest.cc +++ b/chromeos/network/shill_property_handler_unittest.cc @@ -177,7 +177,7 @@ class ShillPropertyHandlerTest : public testing::Test { virtual void SetUp() OVERRIDE { // Initialize DBusThreadManager with a stub implementation. - DBusThreadManager::InitializeWithStub(); + DBusThreadManager::Initialize(); // Get the test interface for manager / device / service and clear the // default stub properties. manager_test_ = diff --git a/content/browser/geolocation/wifi_data_provider_chromeos_unittest.cc b/content/browser/geolocation/wifi_data_provider_chromeos_unittest.cc index f282f31..4538d02 100644 --- a/content/browser/geolocation/wifi_data_provider_chromeos_unittest.cc +++ b/content/browser/geolocation/wifi_data_provider_chromeos_unittest.cc @@ -20,7 +20,7 @@ class GeolocationChromeOsWifiDataProviderTest : public testing::Test { } virtual void SetUp() OVERRIDE { - chromeos::DBusThreadManager::InitializeWithStub(); + chromeos::DBusThreadManager::Initialize(); chromeos::NetworkHandler::Initialize(); manager_client_ = chromeos::DBusThreadManager::Get()->GetShillManagerClient(); diff --git a/device/bluetooth/bluetooth_chromeos_unittest.cc b/device/bluetooth/bluetooth_chromeos_unittest.cc index 87b454f..118499e 100644 --- a/device/bluetooth/bluetooth_chromeos_unittest.cc +++ b/device/bluetooth/bluetooth_chromeos_unittest.cc @@ -5,12 +5,12 @@ #include "base/memory/scoped_vector.h" #include "base/message_loop/message_loop.h" #include "base/strings/utf_string_conversions.h" +#include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/dbus/fake_bluetooth_adapter_client.h" #include "chromeos/dbus/fake_bluetooth_agent_manager_client.h" #include "chromeos/dbus/fake_bluetooth_device_client.h" #include "chromeos/dbus/fake_bluetooth_gatt_service_client.h" #include "chromeos/dbus/fake_bluetooth_input_client.h" -#include "chromeos/dbus/fake_dbus_thread_manager.h" #include "dbus/object_path.h" #include "device/bluetooth/bluetooth_adapter.h" #include "device/bluetooth/bluetooth_adapter_chromeos.h" @@ -234,23 +234,23 @@ class TestPairingDelegate : public BluetoothDevice::PairingDelegate { class BluetoothChromeOSTest : public testing::Test { public: virtual void SetUp() { - FakeDBusThreadManager* fake_dbus_thread_manager = new FakeDBusThreadManager; + scoped_ptr<DBusThreadManagerSetter> dbus_setter = + chromeos::DBusThreadManager::GetSetterForTesting(); // We need to initialize DBusThreadManager early to prevent // Bluetooth*::Create() methods from picking the real instead of fake // implementations. - DBusThreadManager::InitializeForTesting(fake_dbus_thread_manager); fake_bluetooth_adapter_client_ = new FakeBluetoothAdapterClient; - fake_dbus_thread_manager->SetBluetoothAdapterClient( + dbus_setter->SetBluetoothAdapterClient( scoped_ptr<BluetoothAdapterClient>(fake_bluetooth_adapter_client_)); fake_bluetooth_device_client_ = new FakeBluetoothDeviceClient; - fake_dbus_thread_manager->SetBluetoothDeviceClient( + dbus_setter->SetBluetoothDeviceClient( scoped_ptr<BluetoothDeviceClient>(fake_bluetooth_device_client_)); - fake_dbus_thread_manager->SetBluetoothInputClient( + dbus_setter->SetBluetoothInputClient( scoped_ptr<BluetoothInputClient>(new FakeBluetoothInputClient)); - fake_dbus_thread_manager->SetBluetoothAgentManagerClient( + dbus_setter->SetBluetoothAgentManagerClient( scoped_ptr<BluetoothAgentManagerClient>( new FakeBluetoothAgentManagerClient)); - fake_dbus_thread_manager->SetBluetoothGattServiceClient( + dbus_setter->SetBluetoothGattServiceClient( scoped_ptr<BluetoothGattServiceClient>( new FakeBluetoothGattServiceClient)); diff --git a/device/bluetooth/bluetooth_gatt_chromeos_unittest.cc b/device/bluetooth/bluetooth_gatt_chromeos_unittest.cc index d3f78cb..8022842 100644 --- a/device/bluetooth/bluetooth_gatt_chromeos_unittest.cc +++ b/device/bluetooth/bluetooth_gatt_chromeos_unittest.cc @@ -5,6 +5,7 @@ #include "base/memory/scoped_vector.h" #include "base/message_loop/message_loop.h" #include "base/run_loop.h" +#include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/dbus/fake_bluetooth_adapter_client.h" #include "chromeos/dbus/fake_bluetooth_agent_manager_client.h" #include "chromeos/dbus/fake_bluetooth_device_client.h" @@ -12,7 +13,6 @@ #include "chromeos/dbus/fake_bluetooth_gatt_descriptor_client.h" #include "chromeos/dbus/fake_bluetooth_gatt_service_client.h" #include "chromeos/dbus/fake_bluetooth_input_client.h" -#include "chromeos/dbus/fake_dbus_thread_manager.h" #include "dbus/object_path.h" #include "device/bluetooth/bluetooth_adapter.h" #include "device/bluetooth/bluetooth_adapter_factory.h" @@ -281,7 +281,8 @@ class BluetoothGattChromeOSTest : public testing::Test { } virtual void SetUp() { - FakeDBusThreadManager* fake_dbus_thread_manager = new FakeDBusThreadManager; + scoped_ptr<DBusThreadManagerSetter> dbus_setter = + chromeos::DBusThreadManager::GetSetterForTesting(); fake_bluetooth_device_client_ = new FakeBluetoothDeviceClient; fake_bluetooth_gatt_service_client_ = new FakeBluetoothGattServiceClient; @@ -289,26 +290,25 @@ class BluetoothGattChromeOSTest : public testing::Test { new FakeBluetoothGattCharacteristicClient; fake_bluetooth_gatt_descriptor_client_ = new FakeBluetoothGattDescriptorClient; - fake_dbus_thread_manager->SetBluetoothDeviceClient( + dbus_setter->SetBluetoothDeviceClient( scoped_ptr<BluetoothDeviceClient>( fake_bluetooth_device_client_)); - fake_dbus_thread_manager->SetBluetoothGattServiceClient( + dbus_setter->SetBluetoothGattServiceClient( scoped_ptr<BluetoothGattServiceClient>( fake_bluetooth_gatt_service_client_)); - fake_dbus_thread_manager->SetBluetoothGattCharacteristicClient( + dbus_setter->SetBluetoothGattCharacteristicClient( scoped_ptr<BluetoothGattCharacteristicClient>( fake_bluetooth_gatt_characteristic_client_)); - fake_dbus_thread_manager->SetBluetoothGattDescriptorClient( + dbus_setter->SetBluetoothGattDescriptorClient( scoped_ptr<BluetoothGattDescriptorClient>( fake_bluetooth_gatt_descriptor_client_)); - fake_dbus_thread_manager->SetBluetoothAdapterClient( + dbus_setter->SetBluetoothAdapterClient( scoped_ptr<BluetoothAdapterClient>(new FakeBluetoothAdapterClient)); - fake_dbus_thread_manager->SetBluetoothInputClient( + dbus_setter->SetBluetoothInputClient( scoped_ptr<BluetoothInputClient>(new FakeBluetoothInputClient)); - fake_dbus_thread_manager->SetBluetoothAgentManagerClient( + dbus_setter->SetBluetoothAgentManagerClient( scoped_ptr<BluetoothAgentManagerClient>( new FakeBluetoothAgentManagerClient)); - DBusThreadManager::InitializeForTesting(fake_dbus_thread_manager); GetAdapter(); diff --git a/device/bluetooth/bluetooth_socket_chromeos_unittest.cc b/device/bluetooth/bluetooth_socket_chromeos_unittest.cc index e4079f0..e9ee1df 100644 --- a/device/bluetooth/bluetooth_socket_chromeos_unittest.cc +++ b/device/bluetooth/bluetooth_socket_chromeos_unittest.cc @@ -5,13 +5,13 @@ #include "base/bind.h" #include "base/memory/ref_counted.h" #include "base/message_loop/message_loop.h" +#include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/dbus/fake_bluetooth_adapter_client.h" #include "chromeos/dbus/fake_bluetooth_agent_manager_client.h" #include "chromeos/dbus/fake_bluetooth_device_client.h" #include "chromeos/dbus/fake_bluetooth_gatt_service_client.h" #include "chromeos/dbus/fake_bluetooth_input_client.h" #include "chromeos/dbus/fake_bluetooth_profile_manager_client.h" -#include "chromeos/dbus/fake_dbus_thread_manager.h" #include "device/bluetooth/bluetooth_adapter.h" #include "device/bluetooth/bluetooth_adapter_chromeos.h" #include "device/bluetooth/bluetooth_adapter_factory.h" @@ -50,26 +50,25 @@ class BluetoothSocketChromeOSTest : public testing::Test { last_reason_(BluetoothSocket::kSystemError) {} virtual void SetUp() OVERRIDE { - scoped_ptr<FakeDBusThreadManager> fake_dbus_thread_manager( - new FakeDBusThreadManager); + scoped_ptr<DBusThreadManagerSetter> dbus_setter = + DBusThreadManager::GetSetterForTesting(); - fake_dbus_thread_manager->SetBluetoothAdapterClient( + dbus_setter->SetBluetoothAdapterClient( scoped_ptr<BluetoothAdapterClient>(new FakeBluetoothAdapterClient)); - fake_dbus_thread_manager->SetBluetoothAgentManagerClient( + dbus_setter->SetBluetoothAgentManagerClient( scoped_ptr<BluetoothAgentManagerClient>( new FakeBluetoothAgentManagerClient)); - fake_dbus_thread_manager->SetBluetoothDeviceClient( + dbus_setter->SetBluetoothDeviceClient( scoped_ptr<BluetoothDeviceClient>(new FakeBluetoothDeviceClient)); - fake_dbus_thread_manager->SetBluetoothGattServiceClient( + dbus_setter->SetBluetoothGattServiceClient( scoped_ptr<BluetoothGattServiceClient>( new FakeBluetoothGattServiceClient)); - fake_dbus_thread_manager->SetBluetoothInputClient( + dbus_setter->SetBluetoothInputClient( scoped_ptr<BluetoothInputClient>(new FakeBluetoothInputClient)); - fake_dbus_thread_manager->SetBluetoothProfileManagerClient( + dbus_setter->SetBluetoothProfileManagerClient( scoped_ptr<BluetoothProfileManagerClient>( new FakeBluetoothProfileManagerClient)); - DBusThreadManager::InitializeForTesting(fake_dbus_thread_manager.release()); BluetoothSocketThread::Get(); // Grab a pointer to the adapter. diff --git a/device/nfc/nfc_chromeos_unittest.cc b/device/nfc/nfc_chromeos_unittest.cc index 672780f..d748b78 100644 --- a/device/nfc/nfc_chromeos_unittest.cc +++ b/device/nfc/nfc_chromeos_unittest.cc @@ -142,7 +142,7 @@ class TestObserver : public NfcAdapter::Observer, class NfcChromeOSTest : public testing::Test { public: virtual void SetUp() { - DBusThreadManager::InitializeWithStub(); + DBusThreadManager::Initialize(); fake_nfc_adapter_client_ = static_cast<FakeNfcAdapterClient*>( DBusThreadManager::Get()->GetNfcAdapterClient()); fake_nfc_device_client_ = static_cast<FakeNfcDeviceClient*>( diff --git a/extensions/shell/browser/shell_desktop_controller_unittest.cc b/extensions/shell/browser/shell_desktop_controller_unittest.cc index e72bd73..b62e6e8 100644 --- a/extensions/shell/browser/shell_desktop_controller_unittest.cc +++ b/extensions/shell/browser/shell_desktop_controller_unittest.cc @@ -11,7 +11,6 @@ #if defined(OS_CHROMEOS) #include "chromeos/dbus/dbus_thread_manager.h" -#include "chromeos/dbus/fake_dbus_thread_manager.h" #include "chromeos/dbus/fake_power_manager_client.h" #endif @@ -29,12 +28,11 @@ class ShellDesktopControllerTest : public aura::test::AuraTestBase { virtual void SetUp() OVERRIDE { #if defined(OS_CHROMEOS) - chromeos::FakeDBusThreadManager* manager = - new chromeos::FakeDBusThreadManager(); + scoped_ptr<chromeos::DBusThreadManagerSetter> dbus_setter = + chromeos::DBusThreadManager::GetSetterForTesting(); power_manager_client_ = new chromeos::FakePowerManagerClient(); - manager->SetPowerManagerClient(make_scoped_ptr(power_manager_client_). + dbus_setter->SetPowerManagerClient(make_scoped_ptr(power_manager_client_). PassAs<chromeos::PowerManagerClient>()); - chromeos::DBusThreadManager::InitializeForTesting(manager); #endif aura::test::AuraTestBase::SetUp(); controller_.reset(new ShellDesktopController()); |