Commit 66668ed3 authored by tengs's avatar tengs Committed by Commit bot

Add test case for unloading Easy Unlock app when system suspends.

BUG=410082

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

Cr-Commit-Position: refs/heads/master@{#295624}
parent f01542da
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser.h"
#include "chrome/common/extensions/extension_constants.h" #include "chrome/common/extensions/extension_constants.h"
#include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/in_process_browser_test.h"
#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/fake_power_manager_client.h"
#include "components/policy/core/browser/browser_policy_connector.h" #include "components/policy/core/browser/browser_policy_connector.h"
#include "components/policy/core/common/mock_configuration_policy_provider.h" #include "components/policy/core/common/mock_configuration_policy_provider.h"
#include "components/policy/core/common/policy_map.h" #include "components/policy/core/common/policy_map.h"
...@@ -28,6 +30,9 @@ ...@@ -28,6 +30,9 @@
#include "policy/policy_constants.h" #include "policy/policy_constants.h"
#include "testing/gmock/include/gmock/gmock.h" #include "testing/gmock/include/gmock/gmock.h"
using chromeos::DBusThreadManagerSetter;
using chromeos::FakePowerManagerClient;
using chromeos::PowerManagerClient;
using chromeos::ProfileHelper; using chromeos::ProfileHelper;
using chromeos::LoginManagerTest; using chromeos::LoginManagerTest;
using chromeos::StartupUtils; using chromeos::StartupUtils;
...@@ -100,6 +105,12 @@ class EasyUnlockServiceTest : public InProcessBrowserTest { ...@@ -100,6 +105,12 @@ class EasyUnlockServiceTest : public InProcessBrowserTest {
mock_adapter_ = new testing::NiceMock<MockBluetoothAdapter>(); mock_adapter_ = new testing::NiceMock<MockBluetoothAdapter>();
SetUpBluetoothMock(mock_adapter_, is_bluetooth_adapter_present_); SetUpBluetoothMock(mock_adapter_, is_bluetooth_adapter_present_);
scoped_ptr<DBusThreadManagerSetter> dbus_setter =
chromeos::DBusThreadManager::GetSetterForTesting();
power_manager_client_ = new FakePowerManagerClient;
dbus_setter->SetPowerManagerClient(
scoped_ptr<PowerManagerClient>(power_manager_client_));
} }
Profile* profile() const { return browser()->profile(); } Profile* profile() const { return browser()->profile(); }
...@@ -112,10 +123,15 @@ class EasyUnlockServiceTest : public InProcessBrowserTest { ...@@ -112,10 +123,15 @@ class EasyUnlockServiceTest : public InProcessBrowserTest {
is_bluetooth_adapter_present_ = is_present; is_bluetooth_adapter_present_ = is_present;
} }
FakePowerManagerClient* power_manager_client() {
return power_manager_client_;
}
private: private:
policy::MockConfigurationPolicyProvider provider_; policy::MockConfigurationPolicyProvider provider_;
scoped_refptr<testing::NiceMock<MockBluetoothAdapter> > mock_adapter_; scoped_refptr<testing::NiceMock<MockBluetoothAdapter> > mock_adapter_;
bool is_bluetooth_adapter_present_; bool is_bluetooth_adapter_present_;
FakePowerManagerClient* power_manager_client_;
DISALLOW_COPY_AND_ASSIGN(EasyUnlockServiceTest); DISALLOW_COPY_AND_ASSIGN(EasyUnlockServiceTest);
}; };
...@@ -128,6 +144,16 @@ IN_PROC_BROWSER_TEST_F(EasyUnlockServiceTest, DefaultOn) { ...@@ -128,6 +144,16 @@ IN_PROC_BROWSER_TEST_F(EasyUnlockServiceTest, DefaultOn) {
#endif #endif
} }
#if defined(GOOGLE_CHROME_BUILD)
IN_PROC_BROWSER_TEST_F(EasyUnlockServiceTest, UnloadsOnSuspend) {
EXPECT_TRUE(HasEasyUnlockApp());
power_manager_client()->SendSuspendImminent();
EXPECT_FALSE(HasEasyUnlockApp());
power_manager_client()->SendSuspendDone();
EXPECT_TRUE(HasEasyUnlockApp());
}
#endif
class EasyUnlockServiceNoBluetoothTest : public EasyUnlockServiceTest { class EasyUnlockServiceNoBluetoothTest : public EasyUnlockServiceTest {
public: public:
EasyUnlockServiceNoBluetoothTest() {} EasyUnlockServiceNoBluetoothTest() {}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment