Alex Deymo | aea4c1c | 2015-08-19 20:24:43 -0700 | [diff] [blame] | 1 | // |
| 2 | // Copyright (C) 2009 The Android Open Source Project |
| 3 | // |
| 4 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | // you may not use this file except in compliance with the License. |
| 6 | // You may obtain a copy of the License at |
| 7 | // |
| 8 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | // |
| 10 | // Unless required by applicable law or agreed to in writing, software |
| 11 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | // See the License for the specific language governing permissions and |
| 14 | // limitations under the License. |
| 15 | // |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 16 | |
Alex Deymo | 39910dc | 2015-11-09 17:04:30 -0800 | [diff] [blame] | 17 | #include "update_engine/common/action_pipe.h" |
Alex Deymo | aab50e3 | 2014-11-10 19:55:35 -0800 | [diff] [blame] | 18 | |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 19 | #include <gtest/gtest.h> |
Alex Deymo | 39910dc | 2015-11-09 17:04:30 -0800 | [diff] [blame] | 20 | #include <string> |
| 21 | #include "update_engine/common/action.h" |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 22 | |
Andrew de los Reyes | 4fe15d0 | 2009-12-10 19:01:36 -0800 | [diff] [blame] | 23 | using std::string; |
| 24 | |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 25 | namespace chromeos_update_engine { |
| 26 | |
| 27 | using chromeos_update_engine::ActionPipe; |
| 28 | |
| 29 | class ActionPipeTestAction; |
| 30 | |
Amin Hassani | b268959 | 2019-01-13 17:04:28 -0800 | [diff] [blame] | 31 | template <> |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 32 | class ActionTraits<ActionPipeTestAction> { |
| 33 | public: |
| 34 | typedef string OutputObjectType; |
| 35 | typedef string InputObjectType; |
| 36 | }; |
| 37 | |
| 38 | // This is a simple Action class for testing. |
Yunlian Jiang | a178e5e | 2013-04-05 14:41:56 -0700 | [diff] [blame] | 39 | class ActionPipeTestAction : public Action<ActionPipeTestAction> { |
| 40 | public: |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 41 | typedef string InputObjectType; |
| 42 | typedef string OutputObjectType; |
| 43 | ActionPipe<string>* in_pipe() { return in_pipe_.get(); } |
| 44 | ActionPipe<string>* out_pipe() { return out_pipe_.get(); } |
| 45 | void PerformAction() {} |
| 46 | string Type() const { return "ActionPipeTestAction"; } |
| 47 | }; |
| 48 | |
Amin Hassani | b268959 | 2019-01-13 17:04:28 -0800 | [diff] [blame] | 49 | class ActionPipeTest : public ::testing::Test {}; |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 50 | |
| 51 | // This test creates two simple Actions and sends a message via an ActionPipe |
| 52 | // from one to the other. |
| 53 | TEST(ActionPipeTest, SimpleTest) { |
| 54 | ActionPipeTestAction a, b; |
| 55 | BondActions(&a, &b); |
| 56 | a.out_pipe()->set_contents("foo"); |
| 57 | EXPECT_EQ("foo", b.in_pipe()->contents()); |
| 58 | } |
| 59 | |
| 60 | } // namespace chromeos_update_engine |