OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/extensions/api/push_messaging/push_messaging_invalidati
on_handler.h" | 5 #include "chrome/browser/extensions/api/push_messaging/push_messaging_invalidati
on_handler.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "chrome/browser/extensions/api/push_messaging/push_messaging_invalidati
on_handler_delegate.h" | 9 #include "chrome/browser/extensions/api/push_messaging/push_messaging_invalidati
on_handler_delegate.h" |
10 #include "chrome/browser/sync/invalidation_frontend.h" | 10 #include "chrome/browser/sync/invalidation_frontend.h" |
11 #include "google/cacheinvalidation/types.pb.h" | 11 #include "google/cacheinvalidation/types.pb.h" |
12 #include "testing/gmock/include/gmock/gmock.h" | 12 #include "testing/gmock/include/gmock/gmock.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
14 | 14 |
15 using ::testing::_; | 15 using ::testing::_; |
16 using ::testing::InSequence; | 16 using ::testing::InSequence; |
17 using ::testing::NotNull; | 17 using ::testing::NotNull; |
18 using ::testing::SaveArg; | 18 using ::testing::SaveArg; |
19 using ::testing::StrictMock; | 19 using ::testing::StrictMock; |
20 | 20 |
21 namespace extensions { | 21 namespace extensions { |
22 | 22 |
23 namespace { | 23 namespace { |
24 | 24 |
25 class MockInvalidationFrontend : public InvalidationFrontend { | 25 class MockInvalidationFrontend : public InvalidationFrontend { |
26 public: | 26 public: |
27 MockInvalidationFrontend(); | 27 MockInvalidationFrontend(); |
28 ~MockInvalidationFrontend(); | 28 ~MockInvalidationFrontend(); |
29 MOCK_METHOD1(RegisterInvalidationHandler, | 29 MOCK_METHOD1(RegisterInvalidationHandler, |
30 void(syncer::SyncNotifierObserver*)); | 30 void(syncer::InvalidationHandler*)); |
31 MOCK_METHOD2(UpdateRegisteredInvalidationIds, | 31 MOCK_METHOD2(UpdateRegisteredInvalidationIds, |
32 void(syncer::SyncNotifierObserver*, const syncer::ObjectIdSet&)); | 32 void(syncer::InvalidationHandler*, const syncer::ObjectIdSet&)); |
33 MOCK_METHOD1(UnregisterInvalidationHandler, | 33 MOCK_METHOD1(UnregisterInvalidationHandler, |
34 void(syncer::SyncNotifierObserver*)); | 34 void(syncer::InvalidationHandler*)); |
35 | 35 |
36 private: | 36 private: |
37 DISALLOW_COPY_AND_ASSIGN(MockInvalidationFrontend); | 37 DISALLOW_COPY_AND_ASSIGN(MockInvalidationFrontend); |
38 }; | 38 }; |
39 | 39 |
40 MockInvalidationFrontend::MockInvalidationFrontend() {} | 40 MockInvalidationFrontend::MockInvalidationFrontend() {} |
41 MockInvalidationFrontend::~MockInvalidationFrontend() {} | 41 MockInvalidationFrontend::~MockInvalidationFrontend() {} |
42 | 42 |
43 class MockInvalidationHandlerDelegate | 43 class MockInvalidationHandlerDelegate |
44 : public PushMessagingInvalidationHandlerDelegate { | 44 : public PushMessagingInvalidationHandlerDelegate { |
(...skipping 14 matching lines...) Expand all Loading... |
59 | 59 |
60 class PushMessagingInvalidationHandlerTest : public ::testing::Test { | 60 class PushMessagingInvalidationHandlerTest : public ::testing::Test { |
61 protected: | 61 protected: |
62 virtual void SetUp() OVERRIDE { | 62 virtual void SetUp() OVERRIDE { |
63 SetUpWithArgs(std::set<std::string>(), syncer::ObjectIdSet()); | 63 SetUpWithArgs(std::set<std::string>(), syncer::ObjectIdSet()); |
64 } | 64 } |
65 | 65 |
66 virtual void SetUpWithArgs(const std::set<std::string>& extension_ids, | 66 virtual void SetUpWithArgs(const std::set<std::string>& extension_ids, |
67 const syncer::ObjectIdSet& expected_ids) { | 67 const syncer::ObjectIdSet& expected_ids) { |
68 InSequence seq; | 68 InSequence seq; |
69 syncer::SyncNotifierObserver* handler[2] = {}; | 69 syncer::InvalidationHandler* handler[2] = {}; |
70 EXPECT_CALL(service_, RegisterInvalidationHandler(NotNull())) | 70 EXPECT_CALL(service_, RegisterInvalidationHandler(NotNull())) |
71 .WillOnce(SaveArg<0>(&handler[0])); | 71 .WillOnce(SaveArg<0>(&handler[0])); |
72 EXPECT_CALL(service_, | 72 EXPECT_CALL(service_, |
73 UpdateRegisteredInvalidationIds(NotNull(), expected_ids)) | 73 UpdateRegisteredInvalidationIds(NotNull(), expected_ids)) |
74 .WillOnce(SaveArg<0>(&handler[1])); | 74 .WillOnce(SaveArg<0>(&handler[1])); |
75 handler_.reset(new PushMessagingInvalidationHandler( | 75 handler_.reset(new PushMessagingInvalidationHandler( |
76 &service_, &delegate_, extension_ids)); | 76 &service_, &delegate_, extension_ids)); |
77 EXPECT_EQ(handler[0], handler[1]); | 77 EXPECT_EQ(handler[0], handler[1]); |
78 EXPECT_EQ(handler_.get(), handler[0]); | 78 EXPECT_EQ(handler_.get(), handler[0]); |
79 | 79 |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 "U/dddddddddddddddddddddddddddddddd/z")); | 188 "U/dddddddddddddddddddddddddddddddd/z")); |
189 // Subchannel out of range. | 189 // Subchannel out of range. |
190 ids.insert(invalidation::ObjectId( | 190 ids.insert(invalidation::ObjectId( |
191 ipc::invalidation::ObjectSource::CHROME_COMPONENTS, | 191 ipc::invalidation::ObjectSource::CHROME_COMPONENTS, |
192 "U/dddddddddddddddddddddddddddddddd/4")); | 192 "U/dddddddddddddddddddddddddddddddd/4")); |
193 handler_->OnIncomingNotification(ObjectIdSetToStateMap(ids, "payload"), | 193 handler_->OnIncomingNotification(ObjectIdSetToStateMap(ids, "payload"), |
194 syncer::REMOTE_NOTIFICATION); | 194 syncer::REMOTE_NOTIFICATION); |
195 } | 195 } |
196 | 196 |
197 } // namespace extensions | 197 } // namespace extensions |
OLD | NEW |