| 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 "chromeos/dbus/blocking_method_caller.h" | 5 #include "chromeos/dbus/blocking_method_caller.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/task_runner.h" | 10 #include "base/task_runner.h" |
| 11 #include "dbus/message.h" | 11 #include "dbus/message.h" |
| 12 #include "dbus/mock_bus.h" | 12 #include "dbus/mock_bus.h" |
| 13 #include "dbus/mock_object_proxy.h" | 13 #include "dbus/mock_object_proxy.h" |
| 14 #include "dbus/object_path.h" | 14 #include "dbus/object_path.h" |
| 15 #include "testing/gmock/include/gmock/gmock.h" | 15 #include "testing/gmock/include/gmock/gmock.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 17 | 17 |
| 18 using ::testing::_; | 18 using ::testing::_; |
| 19 using ::testing::Invoke; | 19 using ::testing::Invoke; |
| 20 using ::testing::Return; | 20 using ::testing::Return; |
| 21 | 21 |
| 22 namespace chromeos { | 22 namespace chromeos { |
| 23 | 23 |
| 24 namespace { | 24 namespace { |
| 25 | 25 |
| 26 class FakeTaskRunner : public base::TaskRunner { | 26 class FakeTaskRunner : public base::TaskRunner { |
| 27 public: | 27 public: |
| 28 virtual bool PostDelayedTask(const tracked_objects::Location& from_here, | 28 virtual bool PostDelayedTask(const tracked_objects::Location& from_here, |
| 29 const base::Closure& task, | 29 const base::Closure& task, |
| 30 base::TimeDelta delay) OVERRIDE { | 30 base::TimeDelta delay) override { |
| 31 task.Run(); | 31 task.Run(); |
| 32 return true; | 32 return true; |
| 33 } | 33 } |
| 34 virtual bool RunsTasksOnCurrentThread() const OVERRIDE { return true; } | 34 virtual bool RunsTasksOnCurrentThread() const override { return true; } |
| 35 | 35 |
| 36 protected: | 36 protected: |
| 37 virtual ~FakeTaskRunner() {} | 37 virtual ~FakeTaskRunner() {} |
| 38 }; | 38 }; |
| 39 | 39 |
| 40 } // namespace | 40 } // namespace |
| 41 | 41 |
| 42 class BlockingMethodCallerTest : public testing::Test { | 42 class BlockingMethodCallerTest : public testing::Test { |
| 43 public: | 43 public: |
| 44 BlockingMethodCallerTest() : task_runner_(new FakeTaskRunner) { | 44 BlockingMethodCallerTest() : task_runner_(new FakeTaskRunner) { |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 // Check the response. | 129 // Check the response. |
| 130 ASSERT_TRUE(response.get()); | 130 ASSERT_TRUE(response.get()); |
| 131 dbus::MessageReader reader(response.get()); | 131 dbus::MessageReader reader(response.get()); |
| 132 std::string text_message; | 132 std::string text_message; |
| 133 ASSERT_TRUE(reader.PopString(&text_message)); | 133 ASSERT_TRUE(reader.PopString(&text_message)); |
| 134 // The text message should be echo'ed back. | 134 // The text message should be echo'ed back. |
| 135 EXPECT_EQ(kHello, text_message); | 135 EXPECT_EQ(kHello, text_message); |
| 136 } | 136 } |
| 137 | 137 |
| 138 } // namespace chromeos | 138 } // namespace chromeos |
| OLD | NEW |