summaryrefslogtreecommitdiff
path: root/tests/test_transient_message.cc
diff options
context:
space:
mode:
authorDaniel Burrows <Daniel Burrows Daniel_Burrows@alumni.brown.edu>2010-07-02 18:58:49 -0700
committerDaniel Burrows <Daniel Burrows Daniel_Burrows@alumni.brown.edu>2010-07-02 18:58:49 -0700
commit8f6afd9a86847d9c4b94dd2fa6acf18f2cbb252e (patch)
tree4533c797e2ed8e4ca52bbfcf2a747cb14c2f0023 /tests/test_transient_message.cc
parent4f75af1c96d21f0a7be0d6fc346ba8aa80c35dff (diff)
downloadaptitude-8f6afd9a86847d9c4b94dd2fa6acf18f2cbb252e.tar.gz
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.
Diffstat (limited to 'tests/test_transient_message.cc')
-rw-r--r--tests/test_transient_message.cc46
1 files changed, 46 insertions, 0 deletions
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)
{
{