summaryrefslogtreecommitdiff
path: root/tests
diff options
authorMikkel Kamstrup Erlandsen <mikkel.kamstrup@gmail.com>2012-01-20 13:12:36 +0100
committerMikkel Kamstrup Erlandsen <mikkel.kamstrup@gmail.com>2012-01-20 13:12:36 +0100
commit65daab96f11249936f5a09538e0cdd2743c3d202 (patch)
tree8a2603a964ae976c35f53ac1ac974a9525717f38 /tests
parent0654f7a2090f1566836de50d4396d432248c3b6a (diff)
More tests for HomeLens
(bzr r1825.2.43)
Diffstat (limited to 'tests')
-rw-r--r--tests/test_home_lens.cpp97
1 files changed, 97 insertions, 0 deletions
diff --git a/tests/test_home_lens.cpp b/tests/test_home_lens.cpp
index bb7b9f7a4..88832b29e 100644
--- a/tests/test_home_lens.cpp
+++ b/tests/test_home_lens.cpp
@@ -1,6 +1,12 @@
#include <gtest/gtest.h>
#include <glib-object.h>
#include <dee.h>
+#include <string>
+#include <stdexcept>
+#include <map>
+#include <memory>
+#include <sigc++/signal.h>
+#include <sigc++/trackable.h>
#include <UnityCore/GLibWrapper.h>
#include <UnityCore/HomeLens.h>
@@ -15,6 +21,87 @@ using namespace unity::dash;
namespace
{
+/*
+ * Mock Lens instance that does not use DBus
+ */
+class StaticTestLens : public Lens
+{
+public:
+ typedef std::shared_ptr<StaticTestLens> Ptr;
+
+ StaticTestLens(string const& id, string const& name, string const& description, string const& search_hint)
+ : Lens(id, "", "", name, "lens-icon.png",
+ description, search_hint, true, "",
+ ModelType::LOCAL) {}
+
+ virtual ~StaticTestLens() {}
+
+ void GlobalSearch(std::string const& search_string)
+ {
+
+ }
+
+ void Search(std::string const& search_string)
+ {
+
+ }
+
+ void Activate(std::string const& uri)
+ {
+
+ }
+
+ void Preview(std::string const& uri)
+ {
+
+ }
+};
+
+/*
+ * Mock Lenses class that comes with 2 pre-allocated lenses
+ */
+class StaticTestLenses : public Lenses
+{
+public:
+ typedef std::shared_ptr<StaticTestLenses> Ptr;
+
+ StaticTestLenses()
+ : lens_1_(new StaticTestLens("first.lens", "First Lens", "The very first lens", "First search hint"))
+ , lens_2_(new StaticTestLens("second.lens", "Second Lens", "The second lens", "Second search hint"))
+ {
+ count.SetGetterFunction(sigc::mem_fun(&list_, &Lenses::LensList::size));
+ list_.push_back(lens_1_);
+ list_.push_back(lens_2_);
+ }
+
+ virtual ~StaticTestLenses() {}
+
+ Lenses::LensList GetLenses() const
+ {
+ return list_;
+ }
+
+ Lens::Ptr GetLens(std::string const& lens_id) const
+ {
+ for (auto lens : list_)
+ {
+ if (lens->id() == lens_id)
+ return lens;
+ }
+ return Lens::Ptr();
+ }
+
+ Lens::Ptr GetLensAtIndex(std::size_t index) const
+ {
+ return list_.at(index);
+ }
+
+private:
+ Lenses::LensList list_;
+ Lens::Ptr lens_1_;
+ Lens::Ptr lens_2_;
+};
+
TEST(TestHomeLens, TestConstruction)
{
HomeLens home_lens_("name", "description", "searchhint");
@@ -41,4 +128,14 @@ TEST(TestHomeLens, TestInitiallyEmpty)
EXPECT_EQ(home_lens_.count(), 0);
}
+TEST(TestHomeLens, TestTwoStaticLenses)
+{
+ HomeLens home_lens_("name", "description", "searchhint");
+ StaticTestLenses lenses_;
+
+ home_lens_.AddLenses(lenses_);
+
+ EXPECT_EQ(home_lens_.count, (size_t) 2);
+}
+
}