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

Unified Diff: components/proximity_auth/cryptauth/cryptauth_device_manager_unittest.cc

Issue 1248533003: Hook up CryptAuthGCMManager to the enrollment and device sync managers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix webui Created 5 years, 5 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: components/proximity_auth/cryptauth/cryptauth_device_manager_unittest.cc
diff --git a/components/proximity_auth/cryptauth/cryptauth_device_manager_unittest.cc b/components/proximity_auth/cryptauth/cryptauth_device_manager_unittest.cc
index bd02b2fa40087c5686de2c1278fe5403a6b9a205..091d19087d7aa9e687adc85ea315bbfe41b85be0 100644
--- a/components/proximity_auth/cryptauth/cryptauth_device_manager_unittest.cc
+++ b/components/proximity_auth/cryptauth/cryptauth_device_manager_unittest.cc
@@ -10,6 +10,7 @@
#include "base/strings/stringprintf.h"
#include "base/test/simple_test_clock.h"
#include "components/proximity_auth/cryptauth/base64url.h"
+#include "components/proximity_auth/cryptauth/fake_cryptauth_gcm_manager.h"
#include "components/proximity_auth/cryptauth/mock_cryptauth_client.h"
#include "components/proximity_auth/cryptauth/mock_sync_scheduler.h"
#include "components/proximity_auth/cryptauth/pref_names.h"
@@ -104,9 +105,11 @@ class TestCryptAuthDeviceManager : public CryptAuthDeviceManager {
public:
TestCryptAuthDeviceManager(scoped_ptr<base::Clock> clock,
scoped_ptr<CryptAuthClientFactory> client_factory,
+ CryptAuthGCMManager* gcm_manager,
PrefService* pref_service)
: CryptAuthDeviceManager(clock.Pass(),
client_factory.Pass(),
+ gcm_manager,
pref_service),
scoped_sync_scheduler_(new NiceMock<MockSyncScheduler>()),
weak_sync_scheduler_factory_(scoped_sync_scheduler_.get()) {}
@@ -147,8 +150,10 @@ class ProximityAuthCryptAuthDeviceManagerTest
: clock_(new base::SimpleTestClock()),
client_factory_(new MockCryptAuthClientFactory(
MockCryptAuthClientFactory::MockType::MAKE_STRICT_MOCKS)),
+ gcm_manager_("existing gcm registration id"),
device_manager_(make_scoped_ptr(clock_),
make_scoped_ptr(client_factory_),
+ &gcm_manager_,
&pref_service_) {
client_factory_->AddObserver(this);
}
@@ -261,6 +266,8 @@ class ProximityAuthCryptAuthDeviceManagerTest
TestingPrefServiceSimple pref_service_;
+ FakeCryptAuthGCMManager gcm_manager_;
+
TestCryptAuthDeviceManager device_manager_;
cryptauth::GetMyDevicesResponse get_my_devices_response_;
@@ -323,7 +330,7 @@ TEST_F(ProximityAuthCryptAuthDeviceManagerTest, InitWithDefaultPrefs) {
clock.Pass(),
make_scoped_ptr(new MockCryptAuthClientFactory(
MockCryptAuthClientFactory::MockType::MAKE_STRICT_MOCKS)),
- &pref_service);
+ &gcm_manager_, &pref_service);
EXPECT_CALL(
*(device_manager.GetSyncScheduler()),
@@ -525,4 +532,22 @@ TEST_F(ProximityAuthCryptAuthDeviceManagerTest, SyncTwoUnlockKeys) {
device_manager_.unlock_keys(), pref_service_);
}
+TEST_F(ProximityAuthCryptAuthDeviceManagerTest, SyncOnGCMPushMessage) {
+ device_manager_.Start();
+
+ EXPECT_CALL(*sync_scheduler(), ForceSync());
+ gcm_manager_.PushResyncMessage();
+
+ FireSchedulerForSync(cryptauth::INVOCATION_REASON_SERVER_INITIATED);
+
+ EXPECT_CALL(*this, OnSyncFinishedProxy(
+ CryptAuthDeviceManager::SyncResult::SUCCESS,
+ CryptAuthDeviceManager::DeviceChangeResult::CHANGED));
+ success_callback_.Run(get_my_devices_response_);
+
+ ExpectUnlockKeysAndPrefAreEqual(std::vector<cryptauth::ExternalDeviceInfo>(
+ 1, get_my_devices_response_.devices(0)),
+ device_manager_.unlock_keys(), pref_service_);
+}
+
} // namespace proximity_auth

Powered by Google App Engine
This is Rietveld 408576698