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

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: rebase 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
« no previous file with comments | « chrome/browser/signin/easy_unlock_service.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 44aaf560a961f5ce3abb023fc18734b7d52b57ae..a90b95933210e964277223936cde81d696355d7b 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_types.h"
#include "components/user_manager/user_manager.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 user_manager::UserManager;
+using device::MockBluetoothAdapter;
using testing::_;
using testing::Return;
@@ -49,11 +52,27 @@ bool HasEasyUnlockAppForProfile(Profile* profile) {
}
#endif
+void SetUpBluetoothMock(
+ scoped_refptr<testing::NiceMock<MockBluetoothAdapter> > mock_adapter,
+ bool is_present) {
+ device::BluetoothAdapterFactory::SetAdapterForTesting(mock_adapter);
+
+ EXPECT_CALL(*mock_adapter, IsPresent())
+ .WillRepeatedly(testing::Return(is_present));
+
+ // These functions are called from ash system tray. They are speculations of
+ // why flaky gmock errors are seen on bots.
+ EXPECT_CALL(*mock_adapter, IsPowered())
+ .WillRepeatedly(testing::Return(true));
+ EXPECT_CALL(*mock_adapter, GetDevices()).WillRepeatedly(
+ testing::Return(device::BluetoothAdapter::ConstDeviceList()));
+}
+
} // namespace
class EasyUnlockServiceTest : public InProcessBrowserTest {
public:
- EasyUnlockServiceTest() {}
+ EasyUnlockServiceTest() : is_bluetooth_adapter_present_(true) {}
virtual ~EasyUnlockServiceTest() {}
void SetEasyUnlockAllowedPolicy(bool allowed) {
@@ -78,6 +97,9 @@ class EasyUnlockServiceTest : public InProcessBrowserTest {
EXPECT_CALL(provider_, IsInitializationComplete(_))
.WillRepeatedly(Return(true));
policy::BrowserPolicyConnector::SetPolicyProviderForTesting(&provider_);
+
+ mock_adapter_ = new testing::NiceMock<MockBluetoothAdapter>();
+ SetUpBluetoothMock(mock_adapter_, is_bluetooth_adapter_present_);
}
Profile* profile() const { return browser()->profile(); }
@@ -86,8 +108,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 +128,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 +222,16 @@ class EasyUnlockServiceMultiProfileTest : public LoginManagerTest {
EasyUnlockServiceMultiProfileTest() : LoginManagerTest(false) {}
virtual ~EasyUnlockServiceMultiProfileTest() {}
+ // InProcessBrowserTest:
+ virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
+ LoginManagerTest::SetUpInProcessBrowserTestFixture();
+
+ mock_adapter_ = new testing::NiceMock<MockBluetoothAdapter>();
+ SetUpBluetoothMock(mock_adapter_, true);
+ }
+
private:
+ scoped_refptr<testing::NiceMock<MockBluetoothAdapter> > mock_adapter_;
DISALLOW_COPY_AND_ASSIGN(EasyUnlockServiceMultiProfileTest);
};
« no previous file with comments | « 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