Back to index

unity  6.0.0
test_dashview_impl.cpp
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2011 Canonical Ltd
00003  *
00004  * This program is free software: you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License version 3 as
00006  * published by the Free Software Foundation.
00007  *
00008  * This program is distributed in the hope that it will be useful,
00009  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00010  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011  * GNU General Public License for more details.
00012  *
00013  * You should have received a copy of the GNU General Public License
00014  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00015  *
00016  * Authored by: Marco Biscaro <marcobiscaro2112@gmail.com>
00017  */
00018 
00019 #include <gmock/gmock.h>
00020 
00021 #include "DashViewPrivate.h"
00022 
00023 using namespace testing;
00024 
00025 using namespace unity::dash::impl;
00026 
00027 namespace
00028 {
00029 
00030 TEST(TestParseLensFilter, TestSimpleString)
00031 {
00032   LensFilter filter = parse_lens_uri("simple");
00033 
00034   EXPECT_THAT(filter.id, Eq("simple"));
00035   EXPECT_TRUE(filter.filters.empty());
00036 }
00037 
00038 TEST(TestParseLensFilter, TestNonFilterParameter)
00039 {
00040   // Only params that start with "filter_" are added.
00041   LensFilter filter = parse_lens_uri("uri?param=test");
00042 
00043   EXPECT_THAT(filter.id, Eq("uri"));
00044   EXPECT_TRUE(filter.filters.empty());
00045 }
00046 
00047 TEST(TestParseLensFilter, TestSingleParameter)
00048 {
00049   LensFilter filter = parse_lens_uri("uri?filter_param=test");
00050 
00051   EXPECT_THAT(filter.id, Eq("uri"));
00052   EXPECT_THAT(filter.filters.size(), Eq(1));
00053   EXPECT_THAT(filter.filters["param"], Eq("test"));
00054 }
00055 
00056 TEST(TestParseLensFilter, TestNoEquals)
00057 {
00058   LensFilter filter = parse_lens_uri("uri?filter_param");
00059 
00060   EXPECT_THAT(filter.id, Eq("uri"));
00061   EXPECT_TRUE(filter.filters.empty());
00062 }
00063 
00064 TEST(TestParseLensFilter, TestEmbeddedEquals)
00065 {
00066   LensFilter filter = parse_lens_uri("uri?filter_param=a=b");
00067 
00068   EXPECT_THAT(filter.id, Eq("uri"));
00069   EXPECT_THAT(filter.filters.size(), Eq(1));
00070   EXPECT_THAT(filter.filters["param"], Eq("a=b"));
00071 }
00072 
00073 TEST(TestParseLensFilter, TestMultipleParameters)
00074 {
00075   LensFilter filter = parse_lens_uri("uri?filter_param1=first&filter_param2=second");
00076 
00077   EXPECT_THAT(filter.id, Eq("uri"));
00078   EXPECT_THAT(filter.filters.size(), Eq(2));
00079   EXPECT_THAT(filter.filters["param1"], Eq("first"));
00080   EXPECT_THAT(filter.filters["param2"], Eq("second"));
00081 }
00082 
00083 }