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 | |
Andrew de los Reyes | 4fe15d0 | 2009-12-10 19:01:36 -0800 | [diff] [blame] | 5 | #include <string> |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 6 | #include <gtest/gtest.h> |
| 7 | #include "update_engine/action.h" |
| 8 | #include "update_engine/action_pipe.h" |
| 9 | |
Andrew de los Reyes | 4fe15d0 | 2009-12-10 19:01:36 -0800 | [diff] [blame] | 10 | using std::string; |
| 11 | |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 12 | namespace chromeos_update_engine { |
| 13 | |
| 14 | using chromeos_update_engine::ActionPipe; |
| 15 | |
| 16 | class ActionPipeTestAction; |
| 17 | |
| 18 | template<> |
| 19 | class ActionTraits<ActionPipeTestAction> { |
| 20 | public: |
| 21 | typedef string OutputObjectType; |
| 22 | typedef string InputObjectType; |
| 23 | }; |
| 24 | |
| 25 | // This is a simple Action class for testing. |
Yunlian Jiang | a178e5e | 2013-04-05 14:41:56 -0700 | [diff] [blame] | 26 | class ActionPipeTestAction : public Action<ActionPipeTestAction> { |
| 27 | public: |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 28 | typedef string InputObjectType; |
| 29 | typedef string OutputObjectType; |
| 30 | ActionPipe<string>* in_pipe() { return in_pipe_.get(); } |
| 31 | ActionPipe<string>* out_pipe() { return out_pipe_.get(); } |
| 32 | void PerformAction() {} |
| 33 | string Type() const { return "ActionPipeTestAction"; } |
| 34 | }; |
| 35 | |
| 36 | class ActionPipeTest : public ::testing::Test { }; |
| 37 | |
| 38 | // This test creates two simple Actions and sends a message via an ActionPipe |
| 39 | // from one to the other. |
| 40 | TEST(ActionPipeTest, SimpleTest) { |
| 41 | ActionPipeTestAction a, b; |
| 42 | BondActions(&a, &b); |
| 43 | a.out_pipe()->set_contents("foo"); |
| 44 | EXPECT_EQ("foo", b.in_pipe()->contents()); |
| 45 | } |
| 46 | |
| 47 | } // namespace chromeos_update_engine |