blob: b0a96b78e019d22542aaab83f80ab3ed846809b0 [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.
26struct ActionPipeTestAction : public Action<ActionPipeTestAction> {
27 typedef string InputObjectType;
28 typedef string OutputObjectType;
29 ActionPipe<string>* in_pipe() { return in_pipe_.get(); }
30 ActionPipe<string>* out_pipe() { return out_pipe_.get(); }
31 void PerformAction() {}
32 string Type() const { return "ActionPipeTestAction"; }
33};
34
35class ActionPipeTest : public ::testing::Test { };
36
37// This test creates two simple Actions and sends a message via an ActionPipe
38// from one to the other.
39TEST(ActionPipeTest, SimpleTest) {
40 ActionPipeTestAction a, b;
41 BondActions(&a, &b);
42 a.out_pipe()->set_contents("foo");
43 EXPECT_EQ("foo", b.in_pipe()->contents());
44}
45
46} // namespace chromeos_update_engine