Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/test/util/output/MemoryWriterTest.cc @ 11479

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

merged branch cpp11_v3 back to trunk

  • Property svn:eol-style set to native
File size: 1.8 KB
RevLine 
[9545]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        };
[10624]16
17        // Fixture
18        class MemoryWriterTest : public ::testing::Test
19        {
20            public:
[11071]21                virtual void SetUp() override
[10624]22                {
23                    // reset output manager
[11071]24                    OutputManager::Testing::getInstancePointer().reset(new OutputManager());
[10624]25                }
26
[11071]27                virtual void TearDown() override
[10624]28                {
29                }
30        };
[9545]31    }
32
[10624]33    TEST_F(MemoryWriterTest, Disable)
[9545]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
[10624]42    TEST_F(MemoryWriterTest, ResendOutput)
[9545]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.