blob: 0f777fb3929eac7682e7b4a21649e69ad9bf29f3 [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
Andrew de los Reyes4fe15d02009-12-10 19:01:36 -08005#include <string>
rspangler@google.com49fdf182009-10-10 00:57:34 +00006#include <gtest/gtest.h>
7#include "update_engine/action.h"
8#include "update_engine/action_pipe.h"
9
Andrew de los Reyes4fe15d02009-12-10 19:01:36 -080010using std::string;
11
rspangler@google.com49fdf182009-10-10 00:57:34 +000012namespace chromeos_update_engine {
13
14using chromeos_update_engine::ActionPipe;
15
16class ActionPipeTestAction;
17
18template<>
19class ActionTraits<ActionPipeTestAction> {
20 public:
21 typedef string OutputObjectType;
22 typedef string InputObjectType;
23};
24
25// This is a simple Action class for testing.
Yunlian Jianga178e5e2013-04-05 14:41:56 -070026class ActionPipeTestAction : public Action<ActionPipeTestAction> {
27 public:
rspangler@google.com49fdf182009-10-10 00:57:34 +000028 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
36class 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.
40TEST(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