#include "chrome/browser/signin/easy_unlock_service.h"
#include "chrome/browser/signin/screenlock_bridge.h"
#include "chrome/grit/generated_resources.h"
-#include "chrome/test/base/testing_browser_process.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/l10n/l10n_util.h"
// Icons used by EasyUnlockScreenlockStateHandler. The icon id values are the
// same as the ones set by ScreenlockBridge.
const char kLockedIconId[] = "locked";
+const char kLockedToBeActivatedIconId[] = "locked-to-be-activated";
const char kUnlockedIconId[] = "unlocked";
const char kSpinnerIconId[] = "spinner";
const char kHardlockedIconId[] = "hardlocked";
show_icon_count_(0u),
auth_type_(OFFLINE_PASSWORD) {
}
- virtual ~TestLockHandler() {}
+ ~TestLockHandler() override {}
// ScreenlockBridge::LockHandler implementation:
- virtual void ShowBannerMessage(const base::string16& message) OVERRIDE {
+ void ShowBannerMessage(const base::string16& message) override {
ASSERT_FALSE(true) << "Should not be reached.";
}
- virtual void ShowUserPodCustomIcon(
+ void ShowUserPodCustomIcon(
const std::string& user_email,
- const ScreenlockBridge::UserPodCustomIconOptions& icon) OVERRIDE {
+ const ScreenlockBridge::UserPodCustomIconOptions& icon) override {
ASSERT_EQ(user_email_, user_email);
++show_icon_count_;
last_custom_icon_ = icon.ToDictionaryValue().Pass();
ValidateCustomIcon();
}
- virtual void HideUserPodCustomIcon(const std::string& user_email) OVERRIDE {
+ void HideUserPodCustomIcon(const std::string& user_email) override {
ASSERT_EQ(user_email_, user_email);
last_custom_icon_.reset();
}
- virtual void EnableInput() OVERRIDE {
+ void EnableInput() override {
ASSERT_FALSE(true) << "Should not be reached.";
}
- virtual void SetAuthType(const std::string& user_email,
- AuthType auth_type,
- const base::string16& auth_value) OVERRIDE {
+ void SetAuthType(const std::string& user_email,
+ AuthType auth_type,
+ const base::string16& auth_value) override {
ASSERT_EQ(user_email_, user_email);
// Generally, this is allowed, but EasyUnlockScreenlockStateHandler should
// avoid resetting the same auth type.
auth_value_ = auth_value;
}
- virtual AuthType GetAuthType(const std::string& user_email) const OVERRIDE {
+ AuthType GetAuthType(const std::string& user_email) const override {
EXPECT_EQ(user_email_, user_email);
return auth_type_;
}
- virtual void Unlock(const std::string& user_email) OVERRIDE {
+ void Unlock(const std::string& user_email) override {
ASSERT_FALSE(true) << "Should not be reached.";
}
- virtual void AttemptEasySignin(const std::string& user_email,
- const std::string& secret,
- const std::string& key_label) OVERRIDE {
+ void AttemptEasySignin(const std::string& user_email,
+ const std::string& secret,
+ const std::string& key_label) override {
ASSERT_FALSE(true) << "Should not be reached.";
}
class EasyUnlockScreenlockStateHandlerTest : public testing::Test {
public:
EasyUnlockScreenlockStateHandlerTest() : user_email_("test_user@gmail.com") {}
- virtual ~EasyUnlockScreenlockStateHandlerTest() {}
-
- virtual void SetUp() OVERRIDE {
- TestingBrowserProcess::GetGlobal()->SetApplicationLocale("en-US");
+ ~EasyUnlockScreenlockStateHandlerTest() override {}
+ void SetUp() override {
// Create and inject fake lock handler to the screenlock bridge.
lock_handler_.reset(new TestLockHandler(user_email_));
ScreenlockBridge* screenlock_bridge = ScreenlockBridge::Get();
screenlock_bridge));
}
- virtual void TearDown() OVERRIDE {
+ void TearDown() override {
ScreenlockBridge::Get()->SetLockHandler(NULL);
lock_handler_.reset();
state_handler_.reset();
EXPECT_EQ(1u, lock_handler_->GetAndResetShowIconCount());
ASSERT_TRUE(lock_handler_->HasCustomIcon());
- EXPECT_EQ(kHardlockedIconId, lock_handler_->GetCustomIconId());
+ EXPECT_EQ(kLockedToBeActivatedIconId, lock_handler_->GetCustomIconId());
state_handler_->ChangeState(
EasyUnlockScreenlockStateHandler::STATE_AUTHENTICATED);
EXPECT_EQ(0u, lock_handler_->GetAndResetShowIconCount());
ASSERT_TRUE(lock_handler_->HasCustomIcon());
- EXPECT_EQ(kHardlockedIconId, lock_handler_->GetCustomIconId());
+ EXPECT_EQ(kLockedToBeActivatedIconId, lock_handler_->GetCustomIconId());
}
TEST_F(EasyUnlockScreenlockStateHandlerTest,
lock_handler_->GetAuthType(user_email_));
}
+TEST_F(EasyUnlockScreenlockStateHandlerTest, NoOverrideOnlineSignin) {
+ lock_handler_->SetAuthType(user_email_,
+ ScreenlockBridge::LockHandler::ONLINE_SIGN_IN,
+ base::string16());
+
+ std::vector<EasyUnlockScreenlockStateHandler::State> states;
+ states.push_back(EasyUnlockScreenlockStateHandler::STATE_NO_BLUETOOTH);
+ states.push_back(EasyUnlockScreenlockStateHandler::STATE_NO_PHONE);
+ states.push_back(EasyUnlockScreenlockStateHandler::STATE_PHONE_UNSUPPORTED);
+ states.push_back(EasyUnlockScreenlockStateHandler::STATE_PHONE_UNLOCKABLE);
+ states.push_back(
+ EasyUnlockScreenlockStateHandler::STATE_PHONE_NOT_AUTHENTICATED);
+ states.push_back(EasyUnlockScreenlockStateHandler::STATE_PHONE_LOCKED);
+ states.push_back(EasyUnlockScreenlockStateHandler::STATE_PHONE_UNLOCKABLE);
+ states.push_back(EasyUnlockScreenlockStateHandler::STATE_PHONE_UNSUPPORTED);
+ states.push_back(EasyUnlockScreenlockStateHandler::STATE_RSSI_TOO_LOW);
+ states.push_back(EasyUnlockScreenlockStateHandler::STATE_TX_POWER_TOO_HIGH);
+ states.push_back(EasyUnlockScreenlockStateHandler::STATE_AUTHENTICATED);
+
+ for (size_t i = 0; i < states.size(); ++i) {
+ state_handler_->ChangeState(states[i]);
+ EXPECT_EQ(ScreenlockBridge::LockHandler::ONLINE_SIGN_IN,
+ lock_handler_->GetAuthType(user_email_));
+ EXPECT_FALSE(lock_handler_->HasCustomIcon());
+ }
+
+ std::vector<EasyUnlockScreenlockStateHandler::HardlockState> hardlock_states;
+ hardlock_states.push_back(EasyUnlockScreenlockStateHandler::NO_HARDLOCK);
+ hardlock_states.push_back(EasyUnlockScreenlockStateHandler::USER_HARDLOCK);
+ hardlock_states.push_back(EasyUnlockScreenlockStateHandler::PAIRING_CHANGED);
+ hardlock_states.push_back(EasyUnlockScreenlockStateHandler::PAIRING_ADDED);
+ hardlock_states.push_back(EasyUnlockScreenlockStateHandler::NO_PAIRING);
+ hardlock_states.push_back(EasyUnlockScreenlockStateHandler::LOGIN_FAILED);
+
+ for (size_t i = 0; i < hardlock_states.size(); ++i) {
+ state_handler_->SetHardlockState(hardlock_states[i]);
+ EXPECT_EQ(ScreenlockBridge::LockHandler::ONLINE_SIGN_IN,
+ lock_handler_->GetAuthType(user_email_));
+ EXPECT_FALSE(lock_handler_->HasCustomIcon());
+ }
+}
+
} // namespace