From a1c7b8b8e4e6e175febf34dc543ee1328e48f8db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Wed, 20 Sep 2017 05:04:10 +0200 Subject: tests MockResults: properly return a truly mock result instead of still using dee (bzr r4253.1.9) --- tests/MockResults.h | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/MockResults.h b/tests/MockResults.h index 0eacdfaec..cb9c4591c 100644 --- a/tests/MockResults.h +++ b/tests/MockResults.h @@ -26,19 +26,44 @@ namespace unity { namespace dash { -struct MockResults : public Results +struct MockResult : Result +{ + MockResult(std::size_t index) + : Result(nullptr, nullptr, nullptr) + { + uri.SetGetterFunction([index] { return "proto://result-" + std::to_string(index); }); + icon_hint.SetGetterFunction([index] { return ""; }); + category_index.SetGetterFunction([index] { return 0; }); + result_type.SetGetterFunction([index] { return 0; }); + mimetype.SetGetterFunction([index] { return "mime-type-" + std::to_string(index); }); + name.SetGetterFunction([index] { return "MockResult " + std::to_string(index); }); + comment.SetGetterFunction([index] { return "Just a pointless result " + std::to_string(index); }); + dnd_uri.SetGetterFunction([index] { return "dnd://mock-result" + std::to_string(index); }); + hints.SetGetterFunction([index] { return glib::HintsMap(); }); + } +}; + +struct MockResults : Results { MockResults(unsigned int count_) : Results(LOCAL) { count.SetGetterFunction([count_] { return count_; }); } + + virtual const Result RowAtIndex(std::size_t index) const override + { + return MockResult(index); + } }; // Template specialization for Result in tests -template<> const Result Model::RowAtIndex(std::size_t index) const; +template<> const Result Model::RowAtIndex(std::size_t index) const +{ + return MockResult(index); +} } } -#endif \ No newline at end of file +#endif -- cgit v1.2.3