diff options
author | Daniel Burrows <dburrows@debian.org> | 2010-07-10 12:33:57 -0700 |
---|---|---|
committer | Daniel Burrows <dburrows@debian.org> | 2010-07-10 12:33:57 -0700 |
commit | f8dc90aedc7ef312a2da37cb7e93af7f49566468 (patch) | |
tree | c70ee1fc930a1d96866026d9e6c7378276636360 | |
parent | 37917fa3270c5b0f690726537b5b121cf2269235 (diff) | |
download | aptitude-f8dc90aedc7ef312a2da37cb7e93af7f49566468.tar.gz |
Split the teletype mock's constructors into default/nice/strict variants too.
-rw-r--r-- | src/cmdline/mocks/teletype.cc | 28 | ||||
-rw-r--r-- | src/cmdline/mocks/teletype.h | 29 | ||||
-rw-r--r-- | tests/test_teletype_mock.cc | 4 | ||||
-rw-r--r-- | tests/test_transient_message.cc | 2 |
4 files changed, 52 insertions, 11 deletions
diff --git a/src/cmdline/mocks/teletype.cc b/src/cmdline/mocks/teletype.cc index 7fac094c..5f18be23 100644 --- a/src/cmdline/mocks/teletype.cc +++ b/src/cmdline/mocks/teletype.cc @@ -29,6 +29,8 @@ using boost::make_shared; using boost::shared_ptr; using testing::AnyNumber; using testing::Invoke; +using testing::NiceMock; +using testing::StrictMock; using testing::_; namespace aptitude @@ -209,14 +211,34 @@ namespace aptitude } shared_ptr<teletype> - create_teletype(const shared_ptr<terminal_locale> &term_locale, - const shared_ptr<terminal_metrics> &term_metrics, - const boost::shared_ptr<terminal_with_combined_output> &term_output) + create_default_teletype(const shared_ptr<terminal_locale> &term_locale, + const shared_ptr<terminal_metrics> &term_metrics, + const boost::shared_ptr<terminal_with_combined_output> &term_output) { return make_shared<teletype_with_terminal>(term_locale, term_metrics, term_output); } + + shared_ptr<teletype> + create_nice_teletype(const shared_ptr<terminal_locale> &term_locale, + const shared_ptr<terminal_metrics> &term_metrics, + const boost::shared_ptr<terminal_with_combined_output> &term_output) + { + return make_shared<NiceMock<teletype_with_terminal> >(term_locale, + term_metrics, + term_output); + } + + shared_ptr<teletype> + create_strict_teletype(const shared_ptr<terminal_locale> &term_locale, + const shared_ptr<terminal_metrics> &term_metrics, + const boost::shared_ptr<terminal_with_combined_output> &term_output) + { + return make_shared<StrictMock<teletype_with_terminal> >(term_locale, + term_metrics, + term_output); + } } } } diff --git a/src/cmdline/mocks/teletype.h b/src/cmdline/mocks/teletype.h index d0b0ae41..5aa76167 100644 --- a/src/cmdline/mocks/teletype.h +++ b/src/cmdline/mocks/teletype.h @@ -20,6 +20,9 @@ #ifndef APTITUDE_CMDLINE_MOCKS_TELETYPE_H #define APTITUDE_CMDLINE_MOCKS_TELETYPE_H +// Local includes: +#include <generic/util/mocks/mock_util.h> + // System includes: #include <boost/algorithm/string.hpp> #include <boost/shared_ptr.hpp> @@ -87,13 +90,29 @@ namespace aptitude MOCK_METHOD0(newline, void()); }; - /** \brief Create a teletype mock specialized to process the - * output from the given terminal. + /** \brief Create a default teletype mock specialized to process + * the output from the given terminal. + */ + boost::shared_ptr<teletype> + create_default_teletype(const boost::shared_ptr<terminal_locale> &term_locale, + const boost::shared_ptr<terminal_metrics> &term_metrics, + const boost::shared_ptr<terminal_with_combined_output> &term_output); + + /** \brief Create a strict teletype mock specialized to process + * the output from the given terminal. + */ + boost::shared_ptr<teletype> + create_strict_teletype(const boost::shared_ptr<terminal_locale> &term_locale, + const boost::shared_ptr<terminal_metrics> &term_metrics, + const boost::shared_ptr<terminal_with_combined_output> &term_output); + + /** \brief Create a nice teletype mock specialized to process + * the output from the given terminal. */ boost::shared_ptr<teletype> - create_teletype(const boost::shared_ptr<terminal_locale> &term_locale, - const boost::shared_ptr<terminal_metrics> &term_metrics, - const boost::shared_ptr<terminal_with_combined_output> &term_output); + create_nice_teletype(const boost::shared_ptr<terminal_locale> &term_locale, + const boost::shared_ptr<terminal_metrics> &term_metrics, + const boost::shared_ptr<terminal_with_combined_output> &term_output); } } } diff --git a/tests/test_teletype_mock.cc b/tests/test_teletype_mock.cc index 66a85b4c..bdcc9469 100644 --- a/tests/test_teletype_mock.cc +++ b/tests/test_teletype_mock.cc @@ -97,7 +97,7 @@ namespace term_locale(mocks::terminal_locale::create_strict()), term_metrics(mocks::terminal_metrics::create_strict()), term_output(mocks::terminal_with_combined_output::create_strict()), - teletype(mocks::create_teletype(term_locale, term_metrics, term_output)) + teletype(mocks::create_strict_teletype(term_locale, term_metrics, term_output)) { EXPECT_CALL(*term_locale, wcwidth(two_column_char)) .WillRepeatedly(Return(2)); @@ -347,7 +347,7 @@ TEST_F(TeletypeTest, TeletypeDoesNotBreakTerminalMock) shared_ptr<mocks::combining_terminal_output> real_term_output = mocks::combining_terminal_output::create_strict(); shared_ptr<mocks::teletype> teletype = - mocks::create_teletype(term_locale, term_metrics, real_term_output); + mocks::create_strict_teletype(term_locale, term_metrics, real_term_output); EXPECT_CALL(*term_metrics, get_screen_width()) .WillRepeatedly(Return(80)); diff --git a/tests/test_transient_message.cc b/tests/test_transient_message.cc index 2844854e..98ddbc1a 100644 --- a/tests/test_transient_message.cc +++ b/tests/test_transient_message.cc @@ -83,7 +83,7 @@ namespace : term_locale(mocks::terminal_locale::create_strict()), term_metrics(create_terminal_metrics()), term_output(create_terminal_output()), - teletype(mocks::create_teletype(term_locale, term_metrics, term_output)), + teletype(mocks::create_strict_teletype(term_locale, term_metrics, term_output)), message(create_transient_message(term_locale, term_metrics, term_output)), widechar(1, two_column_char) { |