summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/cmdline/mocks/terminal.cc35
-rw-r--r--src/cmdline/mocks/terminal.h9
-rw-r--r--tests/test_teletype_mock.cc2
-rw-r--r--tests/test_terminal_mock.cc2
-rw-r--r--tests/test_transient_message.cc2
5 files changed, 42 insertions, 8 deletions
diff --git a/src/cmdline/mocks/terminal.cc b/src/cmdline/mocks/terminal.cc
index 624bc394..1503d6ad 100644
--- a/src/cmdline/mocks/terminal.cc
+++ b/src/cmdline/mocks/terminal.cc
@@ -28,7 +28,9 @@ using boost::make_shared;
using boost::shared_ptr;
using testing::AnyNumber;
using testing::Invoke;
+using testing::NiceMock;
using testing::Return;
+using testing::StrictMock;
using testing::_;
namespace aptitude
@@ -68,12 +70,17 @@ namespace aptitude
void do_write_text(const std::wstring &s);
+ friend class testing::NiceMock<impl>;
+ friend class testing::StrictMock<impl>;
+
public:
void write_text(const std::wstring &s);
void move_to_beginning_of_line();
void flush();
- static shared_ptr<impl> create();
+ static shared_ptr<impl> create_default();
+ static shared_ptr<impl> create_nice();
+ static shared_ptr<impl> create_strict();
};
combining_terminal_output::impl::impl()
@@ -127,14 +134,34 @@ namespace aptitude
{
}
- shared_ptr<combining_terminal_output::impl> combining_terminal_output::impl::create()
+ shared_ptr<combining_terminal_output::impl> combining_terminal_output::impl::create_default()
{
return make_shared<combining_terminal_output::impl>();
}
- shared_ptr<combining_terminal_output> combining_terminal_output::create()
+ shared_ptr<combining_terminal_output::impl> combining_terminal_output::impl::create_nice()
+ {
+ return make_shared<NiceMock<combining_terminal_output::impl> >();
+ }
+
+ shared_ptr<combining_terminal_output::impl> combining_terminal_output::impl::create_strict()
+ {
+ return make_shared<StrictMock<combining_terminal_output::impl> >();
+ }
+
+ shared_ptr<combining_terminal_output> combining_terminal_output::create_default()
+ {
+ return impl::create_default();
+ }
+
+ shared_ptr<combining_terminal_output> combining_terminal_output::create_nice()
+ {
+ return impl::create_nice();
+ }
+
+ shared_ptr<combining_terminal_output> combining_terminal_output::create_strict()
{
- return impl::create();
+ return impl::create_strict();
}
}
}
diff --git a/src/cmdline/mocks/terminal.h b/src/cmdline/mocks/terminal.h
index a866bacb..cbd06f37 100644
--- a/src/cmdline/mocks/terminal.h
+++ b/src/cmdline/mocks/terminal.h
@@ -164,7 +164,14 @@ namespace aptitude
// Mocked because tests might want to override its behavior:
MOCK_METHOD0(output_is_a_terminal, bool());
- static boost::shared_ptr<combining_terminal_output> create();
+ /** \brief Create a default-style mock. */
+ static boost::shared_ptr<combining_terminal_output> create_default();
+
+ /** \brief Create a nice mock. */
+ static boost::shared_ptr<combining_terminal_output> create_nice();
+
+ /** \brief Create a strict mock. */
+ static boost::shared_ptr<combining_terminal_output> create_strict();
};
}
}
diff --git a/tests/test_teletype_mock.cc b/tests/test_teletype_mock.cc
index b8e2997d..66a85b4c 100644
--- a/tests/test_teletype_mock.cc
+++ b/tests/test_teletype_mock.cc
@@ -345,7 +345,7 @@ TEST_F(TeletypeTest, testOverwritePastEOL)
TEST_F(TeletypeTest, TeletypeDoesNotBreakTerminalMock)
{
shared_ptr<mocks::combining_terminal_output> real_term_output =
- mocks::combining_terminal_output::create();
+ mocks::combining_terminal_output::create_strict();
shared_ptr<mocks::teletype> teletype =
mocks::create_teletype(term_locale, term_metrics, real_term_output);
diff --git a/tests/test_terminal_mock.cc b/tests/test_terminal_mock.cc
index 86574f59..b033d42f 100644
--- a/tests/test_terminal_mock.cc
+++ b/tests/test_terminal_mock.cc
@@ -37,7 +37,7 @@ namespace
public:
TerminalMock()
- : terminal(mocks::combining_terminal_output::create())
+ : terminal(mocks::combining_terminal_output::create_strict())
{
}
};
diff --git a/tests/test_transient_message.cc b/tests/test_transient_message.cc
index c0dbd6d9..2844854e 100644
--- a/tests/test_transient_message.cc
+++ b/tests/test_transient_message.cc
@@ -60,7 +60,7 @@ namespace
static shared_ptr<mocks::combining_terminal_output> create_terminal_output()
{
shared_ptr<mocks::combining_terminal_output> rval =
- mocks::combining_terminal_output::create();
+ mocks::combining_terminal_output::create_strict();
EXPECT_CALL(*rval, output_is_a_terminal())
.WillRepeatedly(Return(true));