Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/core7/test/util/output/MemoryWriterTest.cc @ 10929

Last change on this file since 10929 was 10402, checked in by landauf, 10 years ago

fixed tests in util_test which failed when a different order of execution was used

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