Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6076)

Unified Diff: chrome/browser/signin/easy_unlock_service_browsertest_chromeos.cc

Issue 472733002: No Easy unlock if bluetooth is not available. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix uninit var Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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);
};
« chrome/browser/signin/easy_unlock_service.cc ('K') | « chrome/browser/signin/easy_unlock_service.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698