From 8f6afd9a86847d9c4b94dd2fa6acf18f2cbb252e Mon Sep 17 00:00:00 2001 From: Daniel Burrows Date: Fri, 2 Jul 2010 18:58:49 -0700 Subject: Add a routine on transient_message to display a non-wrapped message and move to the next line. This should be useful for things like printing a status message alongside some sort of progress indicator -- set_text() followed by advance() is not really ideal since it truncates the line. --- tests/test_transient_message.cc | 46 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'tests') diff --git a/tests/test_transient_message.cc b/tests/test_transient_message.cc index dd7fccf4..d1b574b5 100644 --- a/tests/test_transient_message.cc +++ b/tests/test_transient_message.cc @@ -36,6 +36,7 @@ using aptitude::cmdline::transient_message; using boost::shared_ptr; using testing::InSequence; using testing::Return; +using testing::StrEq; using testing::Test; using testing::_; @@ -106,6 +107,51 @@ TEST_F(TransientMessage, PreserveAndAdvance) message->preserve_and_advance(); } +TEST_F(TransientMessage, DisplayAndAdvanceBasic) +{ + { + InSequence dummy; + + EXPECT_CALL(*teletype, set_last_line(StrEq(L"abcdefghi"))); + EXPECT_CALL(*teletype, newline()); + } + + message->display_and_advance(L"abcdefghi"); +} + +TEST_F(TransientMessage, DisplayAndAdvanceWrapping) +{ + EXPECT_CALL(*term, get_screen_width()) + .WillRepeatedly(Return(4)); + + { + InSequence dummy; + + EXPECT_CALL(*teletype, set_last_line(StrEq(L"abcd"))); + EXPECT_CALL(*teletype, newline()); + EXPECT_CALL(*teletype, set_last_line(StrEq(L"efgh"))); + EXPECT_CALL(*teletype, newline()); + EXPECT_CALL(*teletype, set_last_line(StrEq(L"ij"))); + EXPECT_CALL(*teletype, newline()); + } + + message->display_and_advance(L"abcdefghij"); +} + +TEST_F(TransientMessage, DisplayAndAdvanceClearsExistingText) +{ + { + InSequence dummy; + + EXPECT_CALL(*teletype, set_last_line(StrTrimmedRightEq(L"xyzw"))); + EXPECT_CALL(*teletype, set_last_line(StrEq(L"abcd"))); + EXPECT_CALL(*teletype, newline()); + } + + message->set_text(L"xyzw"); + message->display_and_advance(L"abcd"); +} + TEST_F(TransientMessage, ClearText) { { -- cgit v1.2.3