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

Unified Diff: chrome/browser/printing/cloud_print/privet_notifications_unittest.cc

Issue 2027883002: Fix PrivetNotificationService::PrivetNotify() silliness. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits Created 4 years, 7 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/printing/cloud_print/privet_notifications.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/printing/cloud_print/privet_notifications_unittest.cc
diff --git a/chrome/browser/printing/cloud_print/privet_notifications_unittest.cc b/chrome/browser/printing/cloud_print/privet_notifications_unittest.cc
index f621eb275f30bc143e0cfeccb985389b18ba5566..7420ffa6bbed762fa58ce0ebe5ae80e564a010c8 100644
--- a/chrome/browser/printing/cloud_print/privet_notifications_unittest.cc
+++ b/chrome/browser/printing/cloud_print/privet_notifications_unittest.cc
@@ -69,8 +69,7 @@ class MockPrivetHttpFactory : public PrivetHTTPAsynchronousFactory {
};
explicit MockPrivetHttpFactory(net::URLRequestContextGetter* request_context)
- : request_context_(request_context) {
- }
+ : request_context_(request_context) {}
std::unique_ptr<PrivetHTTPResolution> CreatePrivetHTTP(
const std::string& name) override {
@@ -78,7 +77,7 @@ class MockPrivetHttpFactory : public PrivetHTTPAsynchronousFactory {
}
private:
- scoped_refptr<net::URLRequestContextGetter> request_context_;
+ scoped_refptr<net::URLRequestContextGetter> request_context_;
};
class PrivetNotificationsListenerTest : public ::testing::Test {
@@ -95,20 +94,16 @@ class PrivetNotificationsListenerTest : public ::testing::Test {
description_.description = kExampleDeviceDescription;
}
- virtual ~PrivetNotificationsListenerTest() {
- }
+ virtual ~PrivetNotificationsListenerTest() {}
bool SuccessfulResponseToInfo(const std::string& response) {
net::TestURLFetcher* fetcher = fetcher_factory_.GetFetcherByID(0);
- EXPECT_TRUE(fetcher);
- EXPECT_EQ(GURL(kDeviceInfoURL), fetcher->GetOriginalURL());
-
if (!fetcher || GURL(kDeviceInfoURL) != fetcher->GetOriginalURL())
return false;
fetcher->SetResponseString(response);
- fetcher->set_status(net::URLRequestStatus(net::URLRequestStatus::SUCCESS,
- net::OK));
+ fetcher->set_status(
+ net::URLRequestStatus(net::URLRequestStatus::SUCCESS, net::OK));
fetcher->set_response_code(200);
fetcher->delegate()->OnURLFetchComplete(fetcher);
return true;
@@ -124,84 +119,63 @@ class PrivetNotificationsListenerTest : public ::testing::Test {
};
TEST_F(PrivetNotificationsListenerTest, DisappearReappearTest) {
- EXPECT_CALL(mock_delegate_, PrivetNotify(
- 1,
- true));
-
- notification_listener_->DeviceChanged(
- kExampleDeviceName,
- description_);
-
- SuccessfulResponseToInfo(kInfoResponseUptime20);
+ EXPECT_CALL(mock_delegate_, PrivetNotify(1, true));
+ notification_listener_->DeviceChanged(kExampleDeviceName, description_);
+ EXPECT_TRUE(SuccessfulResponseToInfo(kInfoResponseUptime20));
EXPECT_CALL(mock_delegate_, PrivetRemoveNotification());
-
- notification_listener_->DeviceRemoved(
- kExampleDeviceName);
-
- notification_listener_->DeviceChanged(
- kExampleDeviceName,
- description_);
-
+ notification_listener_->DeviceRemoved(kExampleDeviceName);
+ notification_listener_->DeviceChanged(kExampleDeviceName, description_);
description_.id = kExampleDeviceID;
-
- notification_listener_->DeviceChanged(
- kExampleDeviceName,
- description_);
+ notification_listener_->DeviceChanged(kExampleDeviceName, description_);
}
TEST_F(PrivetNotificationsListenerTest, RegisterTest) {
- EXPECT_CALL(mock_delegate_, PrivetNotify(
- 1,
- true));
+ EXPECT_CALL(mock_delegate_, PrivetNotify(1, true));
+ notification_listener_->DeviceChanged(kExampleDeviceName, description_);
+ EXPECT_TRUE(SuccessfulResponseToInfo(kInfoResponseUptime20));
- notification_listener_->DeviceChanged(
- kExampleDeviceName,
- description_);
+ EXPECT_CALL(mock_delegate_, PrivetRemoveNotification());
+ description_.id = kExampleDeviceID;
+ notification_listener_->DeviceChanged(kExampleDeviceName, description_);
+}
+
+TEST_F(PrivetNotificationsListenerTest, RepeatedNotification) {
+ EXPECT_CALL(mock_delegate_, PrivetNotify(1, true));
+ notification_listener_->DeviceChanged(kExampleDeviceName, description_);
+ EXPECT_TRUE(SuccessfulResponseToInfo(kInfoResponseUptime20));
- SuccessfulResponseToInfo(kInfoResponseUptime20);
+ EXPECT_CALL(mock_delegate_, PrivetNotify(_, _)).Times(0);
+ notification_listener_->DeviceChanged(kExampleDeviceName, description_);
EXPECT_CALL(mock_delegate_, PrivetRemoveNotification());
+ notification_listener_->DeviceRemoved(kExampleDeviceName);
- description_.id = kExampleDeviceID;
+ EXPECT_CALL(mock_delegate_, PrivetNotify(_, _)).Times(0);
+ notification_listener_->DeviceChanged(kExampleDeviceName, description_);
- notification_listener_->DeviceChanged(
- kExampleDeviceName,
- description_);
+ EXPECT_CALL(mock_delegate_, PrivetRemoveNotification()).Times(0);
+ notification_listener_->DeviceRemoved(kExampleDeviceName);
}
TEST_F(PrivetNotificationsListenerTest, HighUptimeTest) {
- notification_listener_->DeviceChanged(
- kExampleDeviceName,
- description_);
-
- SuccessfulResponseToInfo(kInfoResponseUptime3600);
-
+ notification_listener_->DeviceChanged(kExampleDeviceName, description_);
+ EXPECT_TRUE(SuccessfulResponseToInfo(kInfoResponseUptime3600));
description_.id = kExampleDeviceID;
-
- notification_listener_->DeviceChanged(
- kExampleDeviceName,
- description_);
+ notification_listener_->DeviceChanged(kExampleDeviceName, description_);
}
TEST_F(PrivetNotificationsListenerTest, HTTPErrorTest) {
- notification_listener_->DeviceChanged(
- kExampleDeviceName,
- description_);
-
+ notification_listener_->DeviceChanged(kExampleDeviceName, description_);
net::TestURLFetcher* fetcher = fetcher_factory_.GetFetcherByID(0);
-
- fetcher->set_status(net::URLRequestStatus(net::URLRequestStatus::SUCCESS,
- net::OK));
+ fetcher->set_status(
+ net::URLRequestStatus(net::URLRequestStatus::SUCCESS, net::OK));
fetcher->set_response_code(200);
fetcher->delegate()->OnURLFetchComplete(fetcher);
}
TEST_F(PrivetNotificationsListenerTest, DictionaryErrorTest) {
- notification_listener_->DeviceChanged(
- kExampleDeviceName,
- description_);
-
+ notification_listener_->DeviceChanged(kExampleDeviceName, description_);
SuccessfulResponseToInfo(kInfoResponseNoUptime);
}
« no previous file with comments | « chrome/browser/printing/cloud_print/privet_notifications.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698