blob: 28cf24841179fc00613d460599d418ac07c175a6 [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
5#include <gtest/gtest.h>
6#include "update_engine/action.h"
7#include "update_engine/action_pipe.h"
8
9namespace chromeos_update_engine {
10
11using chromeos_update_engine::ActionPipe;
12
13class ActionPipeTestAction;
14
15template<>
16class ActionTraits<ActionPipeTestAction> {
17 public:
18 typedef string OutputObjectType;
19 typedef string InputObjectType;
20};
21
22// This is a simple Action class for testing.
23struct ActionPipeTestAction : public Action<ActionPipeTestAction> {
24 typedef string InputObjectType;
25 typedef string OutputObjectType;
26 ActionPipe<string>* in_pipe() { return in_pipe_.get(); }
27 ActionPipe<string>* out_pipe() { return out_pipe_.get(); }
28 void PerformAction() {}
29 string Type() const { return "ActionPipeTestAction"; }
30};
31
32class ActionPipeTest : public ::testing::Test { };
33
34// This test creates two simple Actions and sends a message via an ActionPipe
35// from one to the other.
36TEST(ActionPipeTest, SimpleTest) {
37 ActionPipeTestAction a, b;
38 BondActions(&a, &b);
39 a.out_pipe()->set_contents("foo");
40 EXPECT_EQ("foo", b.in_pipe()->contents());
41}
42
43} // namespace chromeos_update_engine