rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame^] | 1 | // Copyright (c) 2009 The Chromium OS Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include <gtest/gtest.h> |
| 6 | #include "update_engine/action.h" |
| 7 | #include "update_engine/action_pipe.h" |
| 8 | |
| 9 | namespace chromeos_update_engine { |
| 10 | |
| 11 | using chromeos_update_engine::ActionPipe; |
| 12 | |
| 13 | class ActionPipeTestAction; |
| 14 | |
| 15 | template<> |
| 16 | class ActionTraits<ActionPipeTestAction> { |
| 17 | public: |
| 18 | typedef string OutputObjectType; |
| 19 | typedef string InputObjectType; |
| 20 | }; |
| 21 | |
| 22 | // This is a simple Action class for testing. |
| 23 | struct ActionPipeTestAction : public Action<ActionPipeTestAction> { |
| 24 | typedef string InputObjectType; |
| 25 | typedef string OutputObjectType; |
| 26 | ActionPipe<string>* in_pipe() { return in_pipe_.get(); } |
| 27 | ActionPipe<string>* out_pipe() { return out_pipe_.get(); } |
| 28 | void PerformAction() {} |
| 29 | string Type() const { return "ActionPipeTestAction"; } |
| 30 | }; |
| 31 | |
| 32 | class ActionPipeTest : public ::testing::Test { }; |
| 33 | |
| 34 | // This test creates two simple Actions and sends a message via an ActionPipe |
| 35 | // from one to the other. |
| 36 | TEST(ActionPipeTest, SimpleTest) { |
| 37 | ActionPipeTestAction a, b; |
| 38 | BondActions(&a, &b); |
| 39 | a.out_pipe()->set_contents("foo"); |
| 40 | EXPECT_EQ("foo", b.in_pipe()->contents()); |
| 41 | } |
| 42 | |
| 43 | } // namespace chromeos_update_engine |