| Index: chrome/browser/signin/easy_unlock_service_browsertest_chromeos.cc
|
| diff --git a/chrome/browser/signin/easy_unlock_service_browsertest_chromeos.cc b/chrome/browser/signin/easy_unlock_service_browsertest_chromeos.cc
|
| index 577120de3258f350dfd276748e057dd0c05b20ae..8b0f614e57e8dcad4d831b5dbb79a2e195c8696e 100644
|
| --- a/chrome/browser/signin/easy_unlock_service_browsertest_chromeos.cc
|
| +++ b/chrome/browser/signin/easy_unlock_service_browsertest_chromeos.cc
|
| @@ -22,6 +22,8 @@
|
| #include "components/policy/core/common/policy_map.h"
|
| #include "components/policy/core/common/policy_types.h"
|
| #include "content/public/common/content_switches.h"
|
| +#include "device/bluetooth/bluetooth_adapter_factory.h"
|
| +#include "device/bluetooth/test/mock_bluetooth_adapter.h"
|
| #include "extensions/browser/extension_system.h"
|
| #include "policy/policy_constants.h"
|
| #include "testing/gmock/include/gmock/gmock.h"
|
| @@ -31,6 +33,7 @@ using chromeos::LoginManagerTest;
|
| using chromeos::StartupUtils;
|
| using chromeos::UserAddingScreen;
|
| using chromeos::UserManager;
|
| +using device::MockBluetoothAdapter;
|
| using testing::_;
|
| using testing::Return;
|
|
|
| @@ -49,11 +52,11 @@ bool HasEasyUnlockAppForProfile(Profile* profile) {
|
| }
|
| #endif
|
|
|
| -} //namespace
|
| +} // namespace
|
|
|
| class EasyUnlockServiceTest : public InProcessBrowserTest {
|
| public:
|
| - EasyUnlockServiceTest() {}
|
| + EasyUnlockServiceTest() : is_bluetooth_adapter_present_(true) {}
|
| virtual ~EasyUnlockServiceTest() {}
|
|
|
| void SetEasyUnlockAllowedPolicy(bool allowed) {
|
| @@ -67,6 +70,14 @@ class EasyUnlockServiceTest : public InProcessBrowserTest {
|
| base::RunLoop().RunUntilIdle();
|
| }
|
|
|
| + void SetupBluetoothMock(bool is_present) {
|
| + mock_adapter_ = new testing::NiceMock<MockBluetoothAdapter>();
|
| + device::BluetoothAdapterFactory::SetAdapterForTesting(mock_adapter_);
|
| +
|
| + EXPECT_CALL(*mock_adapter_, IsPresent())
|
| + .WillRepeatedly(testing::Return(is_present));
|
| + }
|
| +
|
| #if defined(GOOGLE_CHROME_BUILD)
|
| bool HasEasyUnlockApp() const {
|
| return HasEasyUnlockAppForProfile(profile());
|
| @@ -78,6 +89,7 @@ class EasyUnlockServiceTest : public InProcessBrowserTest {
|
| EXPECT_CALL(provider_, IsInitializationComplete(_))
|
| .WillRepeatedly(Return(true));
|
| policy::BrowserPolicyConnector::SetPolicyProviderForTesting(&provider_);
|
| + SetupBluetoothMock(is_bluetooth_adapter_present_);
|
| }
|
|
|
| Profile* profile() const { return browser()->profile(); }
|
| @@ -86,8 +98,14 @@ class EasyUnlockServiceTest : public InProcessBrowserTest {
|
| return EasyUnlockService::Get(profile());
|
| }
|
|
|
| + void set_is_bluetooth_adapter_present(bool is_present) {
|
| + is_bluetooth_adapter_present_ = is_present;
|
| + }
|
| +
|
| private:
|
| policy::MockConfigurationPolicyProvider provider_;
|
| + scoped_refptr<testing::NiceMock<MockBluetoothAdapter> > mock_adapter_;
|
| + bool is_bluetooth_adapter_present_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(EasyUnlockServiceTest);
|
| };
|
| @@ -100,6 +118,28 @@ IN_PROC_BROWSER_TEST_F(EasyUnlockServiceTest, DefaultOn) {
|
| #endif
|
| }
|
|
|
| +class EasyUnlockServiceNoBluetoothTest : public EasyUnlockServiceTest {
|
| + public:
|
| + EasyUnlockServiceNoBluetoothTest() {}
|
| + virtual ~EasyUnlockServiceNoBluetoothTest() {}
|
| +
|
| + // InProcessBrowserTest:
|
| + virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
|
| + set_is_bluetooth_adapter_present(false);
|
| + EasyUnlockServiceTest::SetUpInProcessBrowserTestFixture();
|
| + }
|
| +
|
| + private:
|
| + DISALLOW_COPY_AND_ASSIGN(EasyUnlockServiceNoBluetoothTest);
|
| +};
|
| +
|
| +IN_PROC_BROWSER_TEST_F(EasyUnlockServiceNoBluetoothTest, NoService) {
|
| + EXPECT_FALSE(service()->IsAllowed());
|
| +#if defined(GOOGLE_CHROME_BUILD)
|
| + EXPECT_FALSE(HasEasyUnlockApp());
|
| +#endif
|
| +}
|
| +
|
| class EasyUnlockServiceFinchEnabledTest : public EasyUnlockServiceTest {
|
| public:
|
| EasyUnlockServiceFinchEnabledTest() {}
|
| @@ -172,7 +212,18 @@ class EasyUnlockServiceMultiProfileTest : public LoginManagerTest {
|
| EasyUnlockServiceMultiProfileTest() : LoginManagerTest(false) {}
|
| virtual ~EasyUnlockServiceMultiProfileTest() {}
|
|
|
| + // InProcessBrowserTest:
|
| + virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
|
| + LoginManagerTest::SetUpInProcessBrowserTestFixture();
|
| +
|
| + mock_adapter_ = new testing::NiceMock<MockBluetoothAdapter>();
|
| + device::BluetoothAdapterFactory::SetAdapterForTesting(mock_adapter_);
|
| + EXPECT_CALL(*mock_adapter_, IsPresent())
|
| + .WillRepeatedly(testing::Return(true));
|
| + }
|
| +
|
| private:
|
| + scoped_refptr<testing::NiceMock<MockBluetoothAdapter> > mock_adapter_;
|
| DISALLOW_COPY_AND_ASSIGN(EasyUnlockServiceMultiProfileTest);
|
| };
|
|
|
|
|