diff options
author | akalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-27 23:18:19 +0000 |
---|---|---|
committer | akalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-27 23:18:19 +0000 |
commit | 276a3f8755894f18b6f4dd2a43cb9d7836f66444 (patch) | |
tree | 686607781b8fa74b701326d19d252e29d4b2f1c8 /chrome | |
parent | 51808efc9c1b88b1a11a4897ef0b7d94c1c52cfc (diff) | |
download | chromium_src-276a3f8755894f18b6f4dd2a43cb9d7836f66444.zip chromium_src-276a3f8755894f18b6f4dd2a43cb9d7836f66444.tar.gz chromium_src-276a3f8755894f18b6f4dd2a43cb9d7836f66444.tar.bz2 |
[Sync] Expanded CacheInvalidationPacketHandler unittests.
BUG=None
TEST=New unittests
Review URL: http://codereview.chromium.org/4133003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@64172 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/sync/notifier/cache_invalidation_packet_handler.h | 3 | ||||
-rw-r--r-- | chrome/browser/sync/notifier/cache_invalidation_packet_handler_unittest.cc | 29 |
2 files changed, 26 insertions, 6 deletions
diff --git a/chrome/browser/sync/notifier/cache_invalidation_packet_handler.h b/chrome/browser/sync/notifier/cache_invalidation_packet_handler.h index f4d89e3..16e86ff 100644 --- a/chrome/browser/sync/notifier/cache_invalidation_packet_handler.h +++ b/chrome/browser/sync/notifier/cache_invalidation_packet_handler.h @@ -13,6 +13,7 @@ #include "base/basictypes.h" #include "base/callback.h" +#include "base/gtest_prod_util.h" #include "base/non_thread_safe.h" #include "base/scoped_callback_factory.h" #include "base/scoped_ptr.h" @@ -46,6 +47,8 @@ class CacheInvalidationPacketHandler { ~CacheInvalidationPacketHandler(); private: + FRIEND_TEST(CacheInvalidationPacketHandlerTest, Basic); + void HandleOutboundPacket( invalidation::NetworkEndpoint* const& network_endpoint); diff --git a/chrome/browser/sync/notifier/cache_invalidation_packet_handler_unittest.cc b/chrome/browser/sync/notifier/cache_invalidation_packet_handler_unittest.cc index c636c97..31b7f0a 100644 --- a/chrome/browser/sync/notifier/cache_invalidation_packet_handler_unittest.cc +++ b/chrome/browser/sync/notifier/cache_invalidation_packet_handler_unittest.cc @@ -4,6 +4,7 @@ #include "chrome/browser/sync/notifier/cache_invalidation_packet_handler.h" +#include "base/base64.h" #include "base/message_loop.h" #include "base/weak_ptr.h" #include "google/cacheinvalidation/invalidation-client.h" @@ -16,8 +17,6 @@ namespace sync_notifier { -namespace { - using ::testing::_; using ::testing::NotNull; using ::testing::Return; @@ -75,6 +74,10 @@ TEST_F(CacheInvalidationPacketHandlerTest, Basic) { RegisterOutboundListener(NotNull())).Times(1); EXPECT_CALL(mock_network_endpoint, RegisterOutboundListener(NULL)).Times(1); + const char kInboundMessage[] = "non-bogus"; + EXPECT_CALL(mock_network_endpoint, + HandleInboundMessage(kInboundMessage)).Times(1); + EXPECT_CALL(mock_network_endpoint, TakeOutboundMessage(_)).Times(1); weak_xmpp_client->Start(); buzz::XmppClientSettings settings; @@ -85,10 +88,24 @@ TEST_F(CacheInvalidationPacketHandlerTest, Basic) { // Initialize the XMPP client. message_loop.RunAllPending(); - CacheInvalidationPacketHandler handler( - base_task, &mock_invalidation_client); + { + CacheInvalidationPacketHandler handler( + base_task, &mock_invalidation_client); + // Take care of any tasks posted by the constructor. + message_loop.RunAllPending(); + + { + handler.HandleInboundPacket("bogus"); + std::string inbound_message_encoded; + EXPECT_TRUE( + base::Base64Encode(kInboundMessage, &inbound_message_encoded)); + handler.HandleInboundPacket(inbound_message_encoded); + } + + handler.HandleOutboundPacket(&mock_network_endpoint); + // Take care of any tasks posted by HandleOutboundPacket(). + message_loop.RunAllPending(); + } } -} // namespace - } // namespace sync_notifier |