blob: 3cdd03d1fafc3df46b9335a4c1cfccf792df3dff [file] [log] [blame]
rspangler@google.com49fdf182009-10-10 00:57:34 +00001// 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 Deymoaab50e32014-11-10 19:55:35 -08005#include "update_engine/action_pipe.h"
6
Andrew de los Reyes4fe15d02009-12-10 19:01:36 -08007#include <string>
rspangler@google.com49fdf182009-10-10 00:57:34 +00008#include <gtest/gtest.h>
9#include "update_engine/action.h"
rspangler@google.com49fdf182009-10-10 00:57:34 +000010
Andrew de los Reyes4fe15d02009-12-10 19:01:36 -080011using std::string;
12
rspangler@google.com49fdf182009-10-10 00:57:34 +000013namespace chromeos_update_engine {
14
15using chromeos_update_engine::ActionPipe;
16
17class ActionPipeTestAction;
18
19template<>
20class ActionTraits<ActionPipeTestAction> {
21 public:
22 typedef string OutputObjectType;
23 typedef string InputObjectType;
24};
25
26// This is a simple Action class for testing.
Yunlian Jianga178e5e2013-04-05 14:41:56 -070027class ActionPipeTestAction : public Action<ActionPipeTestAction> {
28 public:
rspangler@google.com49fdf182009-10-10 00:57:34 +000029 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
37class 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.
41TEST(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