| 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 "sync/notifier/chrome_system_resources.h" | 5 #include "sync/notifier/chrome_system_resources.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
| 13 | 13 |
| 14 #include "google/cacheinvalidation/include/types.h" | 14 #include "google/cacheinvalidation/include/types.h" |
| 15 #include "jingle/notifier/listener/fake_push_client.h" |
| 15 #include "sync/notifier/state_writer.h" | 16 #include "sync/notifier/state_writer.h" |
| 16 #include "testing/gmock/include/gmock/gmock.h" | 17 #include "testing/gmock/include/gmock/gmock.h" |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 18 | 19 |
| 19 namespace sync_notifier { | 20 namespace sync_notifier { |
| 20 namespace { | 21 namespace { |
| 21 | 22 |
| 22 using ::testing::_; | 23 using ::testing::_; |
| 23 using ::testing::SaveArg; | 24 using ::testing::SaveArg; |
| 24 | 25 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 41 MOCK_CONST_METHOD1(Run, void(invalidation::Status)); | 42 MOCK_CONST_METHOD1(Run, void(invalidation::Status)); |
| 42 base::Callback<void(invalidation::Status)>* CreateCallback() { | 43 base::Callback<void(invalidation::Status)>* CreateCallback() { |
| 43 return new base::Callback<void(invalidation::Status)>( | 44 return new base::Callback<void(invalidation::Status)>( |
| 44 base::Bind(&MockStorageCallback::Run, base::Unretained(this))); | 45 base::Bind(&MockStorageCallback::Run, base::Unretained(this))); |
| 45 } | 46 } |
| 46 }; | 47 }; |
| 47 | 48 |
| 48 class ChromeSystemResourcesTest : public testing::Test { | 49 class ChromeSystemResourcesTest : public testing::Test { |
| 49 protected: | 50 protected: |
| 50 ChromeSystemResourcesTest() | 51 ChromeSystemResourcesTest() |
| 51 : chrome_system_resources_(&mock_state_writer_) {} | 52 : chrome_system_resources_( |
| 53 scoped_ptr<notifier::PushClient>(new notifier::FakePushClient()), |
| 54 &mock_state_writer_) {} |
| 52 | 55 |
| 53 virtual ~ChromeSystemResourcesTest() {} | 56 virtual ~ChromeSystemResourcesTest() {} |
| 54 | 57 |
| 55 void ScheduleShouldNotRun() { | 58 void ScheduleShouldNotRun() { |
| 56 { | 59 { |
| 57 // Owned by ScheduleImmediately. | 60 // Owned by ScheduleImmediately. |
| 58 MockClosure mock_closure; | 61 MockClosure mock_closure; |
| 59 base::Closure* should_not_run = mock_closure.CreateClosure(); | 62 base::Closure* should_not_run = mock_closure.CreateClosure(); |
| 60 EXPECT_CALL(mock_closure, Run()).Times(0); | 63 EXPECT_CALL(mock_closure, Run()).Times(0); |
| 61 chrome_system_resources_.internal_scheduler()->Schedule( | 64 chrome_system_resources_.internal_scheduler()->Schedule( |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 EXPECT_CALL(mock_storage_callback, Run(_)) | 168 EXPECT_CALL(mock_storage_callback, Run(_)) |
| 166 .WillOnce(SaveArg<0>(&results)); | 169 .WillOnce(SaveArg<0>(&results)); |
| 167 chrome_system_resources_.storage()->WriteKey( | 170 chrome_system_resources_.storage()->WriteKey( |
| 168 "", "state", mock_storage_callback.CreateCallback()); | 171 "", "state", mock_storage_callback.CreateCallback()); |
| 169 message_loop_.RunAllPending(); | 172 message_loop_.RunAllPending(); |
| 170 EXPECT_EQ(invalidation::Status(invalidation::Status::SUCCESS, ""), results); | 173 EXPECT_EQ(invalidation::Status(invalidation::Status::SUCCESS, ""), results); |
| 171 } | 174 } |
| 172 | 175 |
| 173 } // namespace | 176 } // namespace |
| 174 } // namespace notifier | 177 } // namespace notifier |
| OLD | NEW |