2
* Copyright (C) 2012 Canonical Ltd
4
* This program is free software: you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License version 3 as
6
* published by the Free Software Foundation.
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
13
* You should have received a copy of the GNU General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16
* Authored by: Andrea Azzarone <azzaronea@gmail.com>
22
#include <gmock/gmock.h>
24
#include "LensViewPrivate.h"
25
#include "AbstractPlacesGroup.h"
27
using namespace unity;
28
using namespace testing;
33
const int NUM_GROUPS = 4;
35
class TestPlacesGroupImpl : public Test
40
for (int i=0; i<NUM_GROUPS; ++i)
41
groups_vector.push_back(new dash::AbstractPlacesGroup);
44
~TestPlacesGroupImpl()
46
for (int i=0; i<NUM_GROUPS; ++i)
47
delete groups_vector[i];
50
std::list<dash::AbstractPlacesGroup*> GetList()
52
std::list<dash::AbstractPlacesGroup*> ret;
53
std::copy(groups_vector.begin(), groups_vector.end(), std::back_inserter(ret));
57
std::vector<dash::AbstractPlacesGroup*> groups_vector;
61
TEST_F(TestPlacesGroupImpl, TestUpdateDrawSeparatorsEmpty)
63
std::list<dash::AbstractPlacesGroup*> groups;
65
// Just to make sure it doesn't crash.
66
dash::impl::UpdateDrawSeparators(groups);
69
TEST_F(TestPlacesGroupImpl, TestUpdateDrawSeparatorsAllVisible)
71
groups_vector[0]->SetVisible(true);
72
groups_vector[1]->SetVisible(true);
73
groups_vector[2]->SetVisible(true);
74
groups_vector[3]->SetVisible(true);
76
dash::impl::UpdateDrawSeparators(GetList());
78
EXPECT_TRUE(groups_vector[0]->draw_separator);
79
EXPECT_TRUE(groups_vector[1]->draw_separator);
80
EXPECT_TRUE(groups_vector[2]->draw_separator);
81
EXPECT_FALSE(groups_vector[3]->draw_separator);
84
TEST_F(TestPlacesGroupImpl, TestUpdateDrawSeparatorsLastInvisible)
86
groups_vector[0]->SetVisible(true);
87
groups_vector[1]->SetVisible(true);
88
groups_vector[2]->SetVisible(true);
89
groups_vector[3]->SetVisible(false);
91
dash::impl::UpdateDrawSeparators(GetList());
93
EXPECT_TRUE(groups_vector[0]->draw_separator);
94
EXPECT_TRUE(groups_vector[1]->draw_separator);
95
EXPECT_FALSE(groups_vector[2]->draw_separator);
98
TEST_F(TestPlacesGroupImpl, TestUpdateDrawSeparatorsLastTwoInvisible)
100
groups_vector[0]->SetVisible(true);
101
groups_vector[1]->SetVisible(true);
102
groups_vector[2]->SetVisible(false);
103
groups_vector[3]->SetVisible(false);
105
dash::impl::UpdateDrawSeparators(GetList());
107
EXPECT_TRUE(groups_vector[0]->draw_separator);
108
EXPECT_FALSE(groups_vector[1]->draw_separator);
111
TEST_F(TestPlacesGroupImpl, TestUpdateDrawSeparators)
113
groups_vector[0]->SetVisible(true);
114
groups_vector[1]->SetVisible(false);
115
groups_vector[2]->SetVisible(false);
116
groups_vector[3]->SetVisible(true);
118
dash::impl::UpdateDrawSeparators(GetList());
120
EXPECT_TRUE(groups_vector[0]->draw_separator);
121
EXPECT_FALSE(groups_vector[3]->draw_separator);