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

Unified Diff: remoting/protocol/pairing_registry_unittest.cc

Issue 15709005: Linux pairing registry delegate implementation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed Windows and Mac compile errors. Created 7 years, 6 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 | « remoting/protocol/pairing_registry.cc ('k') | remoting/protocol/protocol_mock_objects.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/protocol/pairing_registry_unittest.cc
diff --git a/remoting/protocol/pairing_registry_unittest.cc b/remoting/protocol/pairing_registry_unittest.cc
index a5d8bf2fb8a4c472030264775e5e6a4c1e5db572..460acbe1afcab011df1de3247192b020d08baf40 100644
--- a/remoting/protocol/pairing_registry_unittest.cc
+++ b/remoting/protocol/pairing_registry_unittest.cc
@@ -17,57 +17,47 @@ namespace protocol {
class PairingRegistryTest : public testing::Test {
public:
- virtual void SetUp() OVERRIDE {
- got_secret_ = false;
- }
-
void CompareSecret(const std::string& expected,
PairingRegistry::Pairing actual) {
- EXPECT_EQ(actual.shared_secret(), expected);
+ EXPECT_EQ(expected, actual.shared_secret());
+ secret_ = actual.shared_secret();
got_secret_ = true;
}
protected:
+ std::string secret_;
bool got_secret_;
};
-TEST_F(PairingRegistryTest, GetPairing) {
- PairingRegistry::Pairing client_info =
- PairingRegistry::Pairing::Create("client_name");
+TEST_F(PairingRegistryTest, CreateAndGetPairings) {
MockPairingRegistryDelegate* mock_delegate =
new MockPairingRegistryDelegate();
- mock_delegate->AddPairing(client_info, PairingRegistry::AddPairingCallback());
scoped_ptr<PairingRegistry::Delegate> delegate(mock_delegate);
scoped_refptr<PairingRegistry> registry(new PairingRegistry(delegate.Pass()));
+ PairingRegistry::Pairing pairing_1 = registry->CreatePairing("client_name");
+ mock_delegate->RunCallback();
+ PairingRegistry::Pairing pairing_2 = registry->CreatePairing("client_name");
+ mock_delegate->RunCallback();
- registry->GetPairing(client_info.client_id(),
+ registry->GetPairing(pairing_1.client_id(),
base::Bind(&PairingRegistryTest::CompareSecret,
base::Unretained(this),
- client_info.shared_secret()));
+ pairing_1.shared_secret()));
+ got_secret_ = false;
mock_delegate->RunCallback();
EXPECT_TRUE(got_secret_);
-}
-
-TEST_F(PairingRegistryTest, AddPairing) {
- MockPairingRegistryDelegate* mock_delegate =
- new MockPairingRegistryDelegate();
- scoped_ptr<PairingRegistry::Delegate> delegate(mock_delegate);
-
- scoped_refptr<PairingRegistry> registry(new PairingRegistry(delegate.Pass()));
-
- // Verify that we can create pairings from two clients with the same name, but
- // that they aren't allocated the same client id.
- PairingRegistry::Pairing pairing_1 = registry->CreatePairing("client_name");
- PairingRegistry::Pairing pairing_2 = registry->CreatePairing("client_name");
+ std::string secret_1 = secret_;
- const PairingRegistry::PairedClients& clients =
- mock_delegate->paired_clients();
- ASSERT_EQ(clients.size(), 2u);
- PairingRegistry::Pairing first = clients.begin()->second;
- PairingRegistry::Pairing second = (++clients.begin())->second;
- EXPECT_EQ(first.client_name(), second.client_name());
- EXPECT_NE(first.client_id(), second.client_id());
+ // Check that the second client is paired with a different shared secret.
+ registry->GetPairing(pairing_2.client_id(),
+ base::Bind(&PairingRegistryTest::CompareSecret,
+ base::Unretained(this),
+ pairing_2.shared_secret()));
+ got_secret_ = false;
+ mock_delegate->RunCallback();
+ EXPECT_TRUE(got_secret_);
+ EXPECT_NE(secret_, secret_1);
}
} // namespace protocol
« no previous file with comments | « remoting/protocol/pairing_registry.cc ('k') | remoting/protocol/protocol_mock_objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698