Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/cpp11_v3/test/util/output/MemoryWriterTest.cc @ 11054

Last change on this file since 11054 was 11054, checked in by landauf, 9 years ago

merged branch cpp11_v2 into cpp11_v3

  • Property svn:eol-style set to native
File size: 1.8 KB
Line 
1#include <gtest/gtest.h>
2#include <gmock/gmock.h>
3#include "util/Output.h"
4#include "util/output/MemoryWriter.h"
5#include "util/output/OutputManager.h"
6
7namespace orxonox
8{
9    namespace
10    {
11        class MockOutputListener : public OutputListener
12        {
13            public:
14                MOCK_METHOD3(output, void(OutputLevel, const OutputContextContainer&, const std::vector<std::string>&));
15        };
16
17        // Fixture
18        class MemoryWriterTest : public ::testing::Test
19        {
20            public:
21                virtual void SetUp() override
22                {
23                    // reset output manager
24                    OutputManager::Testing::getInstancePointer().reset(new OutputManager());
25                }
26
27                virtual void TearDown() override
28                {
29                }
30        };
31    }
32
33    TEST_F(MemoryWriterTest, Disable)
34    {
35        EXPECT_EQ(0U, OutputManager::getInstance().getListeners().size());
36        MemoryWriter writer;
37        EXPECT_EQ(1U, OutputManager::getInstance().getListeners().size());
38        writer.disable();
39        EXPECT_EQ(0U, OutputManager::getInstance().getListeners().size());
40    }
41
42    TEST_F(MemoryWriterTest, ResendOutput)
43    {
44        MemoryWriter writer;
45
46        std::vector<std::string> lines;
47        lines.push_back("random line of output");
48        lines.push_back("another line of output");
49
50        writer.unfilteredOutput(level::user_info, context::undefined(), lines);
51        writer.unfilteredOutput(level::verbose, context::xml(), lines);
52
53        MockOutputListener other;
54        other.setLevelMask(level::all);
55
56        EXPECT_CALL(other, output(level::user_info, context::undefined(), lines));
57        EXPECT_CALL(other, output(level::verbose, context::xml(), lines));
58
59        writer.resendOutput(&other);
60    }
61}
Note: See TracBrowser for help on using the repository browser.