diff options
author | Daniel Burrows <Daniel Burrows Daniel_Burrows@alumni.brown.edu> | 2010-05-25 01:03:55 -0700 |
---|---|---|
committer | Daniel Burrows <Daniel Burrows Daniel_Burrows@alumni.brown.edu> | 2010-05-25 01:03:55 -0700 |
commit | f7cfe9bb0487ad521dc40656ae3dd7f94fb29ec3 (patch) | |
tree | bb608887ef71e33460a7f01ba4bb27fb7df5acf5 /tests | |
parent | bb7641484d5fe878dde0ae81818eecf86f645fc3 (diff) | |
download | aptitude-f7cfe9bb0487ad521dc40656ae3dd7f94fb29ec3.tar.gz |
Refine the existing test of the search input controller so it passes.
This modifies the expected behavior to match what I really expect.
Specifically:
* The controller is allowed to set the error message to "".
* After the search text is set to "?installed", the view will return
"?installed' from get_search_text().
Regarding that second point: maybe I should make this "save values and
return them" the default behavior? Although that starts to open up cans
of worms...
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_search_input_controller.cc | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/tests/test_search_input_controller.cc b/tests/test_search_input_controller.cc index 0eb54ba0..91e84e4e 100644 --- a/tests/test_search_input_controller.cc +++ b/tests/test_search_input_controller.cc @@ -34,8 +34,11 @@ using aptitude::matching::pattern; using boost::make_shared; using boost::shared_ptr; using cwidget::util::ref_ptr; +using testing::AnyNumber; +using testing::Expectation; using testing::InSequence; using testing::NiceMock; +using testing::Return; using testing::StrictMock; namespace @@ -120,12 +123,23 @@ BOOST_FIXTURE_TEST_CASE(testEnteringCorrectTextSearches, SearchInputTest) ref_ptr<pattern> p = pattern::make_installed(); Glib::ustring p_text = "?installed"; + // The controller isn't required to call set_error_message(), but it + // should set it to "" if it does. + EXPECT_CALL(*view, set_error_message(Glib::ustring())).Times(AnyNumber()); + + Expectation set_search_text; { InSequence dummy; - EXPECT_CALL(*view, set_search_text(p_text)); + set_search_text = EXPECT_CALL(*view, set_search_text(p_text)); EXPECT_CALL(callbacks, activated(p_text, PatternsEqual(p))); } + // After setting the search text, get_search_text() will return the + // new text. + EXPECT_CALL(*view, get_search_text()) + .After(set_search_text) + .WillRepeatedly(Return(p_text)); + get_controller()->enter_text(p_text); } |