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