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

Unified Diff: chrome/browser/local_discovery/privetv3_session_unittest.cc

Issue 1106183006: Added gcdPrivate.getDeviceInfo function (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@no_establish
Patch Set: Mon Apr 27 22:56:49 PDT 2015 Created 5 years, 8 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/local_discovery/privetv3_session.cc ('k') | chrome/common/extensions/api/gcd_private.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/local_discovery/privetv3_session_unittest.cc
diff --git a/chrome/browser/local_discovery/privetv3_session_unittest.cc b/chrome/browser/local_discovery/privetv3_session_unittest.cc
index 8cf8e89ebdfe851fcdfe4ab1f473150c966b73c5..5cf4ff8065da81cf211d05a0a3e240677502a8b9 100644
--- a/chrome/browser/local_discovery/privetv3_session_unittest.cc
+++ b/chrome/browser/local_discovery/privetv3_session_unittest.cc
@@ -80,15 +80,20 @@ class PrivetV3SessionTest : public testing::Test {
~PrivetV3SessionTest() override {}
- MOCK_METHOD2(OnInitialized, void(Result, const std::vector<PairingType>&));
+ void OnInitialized(Result result, const base::DictionaryValue& info) {
+ info_.MergeDictionary(&info);
+ OnInitializedMock(result, info);
+ }
+
+ MOCK_METHOD2(OnInitializedMock, void(Result, const base::DictionaryValue&));
MOCK_METHOD1(OnPairingStarted, void(Result));
MOCK_METHOD1(OnCodeConfirmed, void(Result));
- MOCK_METHOD2(OnMessageSend, void(Result, const base::DictionaryValue& value));
- MOCK_METHOD1(OnPostData, void(const base::DictionaryValue& data));
+ MOCK_METHOD2(OnMessageSend, void(Result, const base::DictionaryValue&));
+ MOCK_METHOD1(OnPostData, void(const base::DictionaryValue&));
protected:
void SetUp() override {
- EXPECT_CALL(*this, OnInitialized(_, _)).Times(0);
+ EXPECT_CALL(*this, OnInitializedMock(_, _)).Times(0);
EXPECT_CALL(*this, OnPairingStarted(_)).Times(0);
EXPECT_CALL(*this, OnCodeConfirmed(_)).Times(0);
EXPECT_CALL(*this, OnMessageSend(_, _)).Times(0);
@@ -97,6 +102,7 @@ class PrivetV3SessionTest : public testing::Test {
base::Bind(&PrivetV3SessionTest::OnPostData, base::Unretained(this));
}
+ base::DictionaryValue info_;
base::MessageLoop loop_;
base::Closure quit_closure_;
net::FakeURLFetcherFactory fetcher_factory_;
@@ -104,7 +110,8 @@ class PrivetV3SessionTest : public testing::Test {
};
TEST_F(PrivetV3SessionTest, InitError) {
- EXPECT_CALL(*this, OnInitialized(Result::STATUS_CONNECTIONERROR, _)).Times(1);
+ EXPECT_CALL(*this, OnInitializedMock(Result::STATUS_CONNECTIONERROR, _))
+ .Times(1);
fetcher_factory_.SetFakeResponse(GURL("http://host/privet/info"), "",
net::HTTP_OK, net::URLRequestStatus::FAILED);
session_.Init(
@@ -116,7 +123,8 @@ TEST_F(PrivetV3SessionTest, VersionError) {
std::string response(kInfoResponse);
ReplaceFirstSubstringAfterOffset(&response, 0, "3.0", "4.1");
- EXPECT_CALL(*this, OnInitialized(Result::STATUS_SESSIONERROR, _)).Times(1);
+ EXPECT_CALL(*this, OnInitializedMock(Result::STATUS_SESSIONERROR, _))
+ .Times(1);
fetcher_factory_.SetFakeResponse(GURL("http://host/privet/info"), response,
net::HTTP_OK,
net::URLRequestStatus::SUCCESS);
@@ -129,7 +137,8 @@ TEST_F(PrivetV3SessionTest, ModeError) {
std::string response(kInfoResponse);
ReplaceFirstSubstringAfterOffset(&response, 0, "mode", "mode_");
- EXPECT_CALL(*this, OnInitialized(Result::STATUS_SESSIONERROR, _)).Times(1);
+ EXPECT_CALL(*this, OnInitializedMock(Result::STATUS_SESSIONERROR, _))
+ .Times(1);
fetcher_factory_.SetFakeResponse(GURL("http://host/privet/info"), response,
net::HTTP_OK,
net::URLRequestStatus::SUCCESS);
@@ -139,9 +148,8 @@ TEST_F(PrivetV3SessionTest, ModeError) {
}
TEST_F(PrivetV3SessionTest, Pairing) {
- std::vector<PairingType> pairings;
- EXPECT_CALL(*this, OnInitialized(Result::STATUS_SUCCESS, _))
- .WillOnce(SaveArg<1>(&pairings));
+ EXPECT_CALL(*this, OnInitializedMock(Result::STATUS_SUCCESS, _))
+ .Times(1);
fetcher_factory_.SetFakeResponse(GURL("http://host/privet/info"),
kInfoResponse, net::HTTP_OK,
net::URLRequestStatus::SUCCESS);
@@ -150,9 +158,15 @@ TEST_F(PrivetV3SessionTest, Pairing) {
base::Bind(&PrivetV3SessionTest::OnInitialized, base::Unretained(this)));
base::RunLoop().RunUntilIdle();
- EXPECT_EQ(2u, pairings.size());
- EXPECT_EQ(PairingType::PAIRING_TYPE_PINCODE, pairings[0]);
- EXPECT_EQ(PairingType::PAIRING_TYPE_EMBEDDEDCODE, pairings[1]);
+ const base::ListValue* pairing = nullptr;
+ ASSERT_TRUE(info_.GetList("authentication.pairing", &pairing));
+
+ std::string pairing_string;
+ ASSERT_TRUE(pairing->GetString(0, &pairing_string));
+ EXPECT_EQ("pinCode", pairing_string);
+
+ ASSERT_TRUE(pairing->GetString(1, &pairing_string));
+ EXPECT_EQ("embeddedCode", pairing_string);
crypto::P224EncryptedKeyExchange spake(
crypto::P224EncryptedKeyExchange::kPeerTypeServer, "testPin");
@@ -254,7 +268,7 @@ TEST_F(PrivetV3SessionTest, Pairing) {
}
TEST_F(PrivetV3SessionTest, Cancel) {
- EXPECT_CALL(*this, OnInitialized(Result::STATUS_SUCCESS, _));
+ EXPECT_CALL(*this, OnInitializedMock(Result::STATUS_SUCCESS, _)).Times(1);;
fetcher_factory_.SetFakeResponse(GURL("http://host/privet/info"),
kInfoResponse, net::HTTP_OK,
net::URLRequestStatus::SUCCESS);
« no previous file with comments | « chrome/browser/local_discovery/privetv3_session.cc ('k') | chrome/common/extensions/api/gcd_private.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698