~azzar1/unity/lp-1226116

« back to all changes in this revision

Viewing changes to tests/test_lensview_impl.cpp

  • Committer: Daniel van Vugt
  • Date: 2012-03-14 06:24:18 UTC
  • mfrom: (2108 unity)
  • mto: This revision was merged to the branch mainline in revision 2146.
  • Revision ID: daniel.van.vugt@canonical.com-20120314062418-nprucpbr0m7qky5e
MergedĀ latestĀ lp:unity

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2012 Canonical Ltd
 
3
 *
 
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.
 
7
 *
 
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.
 
12
 *
 
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/>.
 
15
 *
 
16
 * Authored by: Andrea Azzarone <azzaronea@gmail.com>
 
17
 */
 
18
 
 
19
#include <list>
 
20
#include <vector>
 
21
 
 
22
#include <gmock/gmock.h>
 
23
 
 
24
#include "LensViewPrivate.h"
 
25
#include "AbstractPlacesGroup.h"
 
26
 
 
27
using namespace unity;
 
28
using namespace testing;
 
29
 
 
30
namespace
 
31
{
 
32
 
 
33
const int NUM_GROUPS = 4;
 
34
 
 
35
class TestPlacesGroupImpl : public Test
 
36
{
 
37
public:
 
38
  TestPlacesGroupImpl()
 
39
  {
 
40
    for (int i=0; i<NUM_GROUPS; ++i)
 
41
      groups_vector.push_back(new dash::AbstractPlacesGroup);
 
42
  }
 
43
 
 
44
  ~TestPlacesGroupImpl()
 
45
  {
 
46
    for (int i=0; i<NUM_GROUPS; ++i)
 
47
      delete groups_vector[i];
 
48
  }
 
49
 
 
50
  std::list<dash::AbstractPlacesGroup*> GetList()
 
51
  {
 
52
    std::list<dash::AbstractPlacesGroup*> ret;
 
53
    std::copy(groups_vector.begin(), groups_vector.end(), std::back_inserter(ret));
 
54
    return ret;
 
55
  }
 
56
 
 
57
  std::vector<dash::AbstractPlacesGroup*> groups_vector;
 
58
};
 
59
 
 
60
 
 
61
TEST_F(TestPlacesGroupImpl, TestUpdateDrawSeparatorsEmpty)
 
62
{
 
63
  std::list<dash::AbstractPlacesGroup*> groups;
 
64
 
 
65
  // Just to make sure it doesn't crash.
 
66
  dash::impl::UpdateDrawSeparators(groups);
 
67
}
 
68
 
 
69
TEST_F(TestPlacesGroupImpl, TestUpdateDrawSeparatorsAllVisible)
 
70
{
 
71
  groups_vector[0]->SetVisible(true);
 
72
  groups_vector[1]->SetVisible(true);
 
73
  groups_vector[2]->SetVisible(true);
 
74
  groups_vector[3]->SetVisible(true);
 
75
 
 
76
  dash::impl::UpdateDrawSeparators(GetList());
 
77
 
 
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);
 
82
}
 
83
 
 
84
TEST_F(TestPlacesGroupImpl, TestUpdateDrawSeparatorsLastInvisible)
 
85
{
 
86
  groups_vector[0]->SetVisible(true);
 
87
  groups_vector[1]->SetVisible(true);
 
88
  groups_vector[2]->SetVisible(true);
 
89
  groups_vector[3]->SetVisible(false);
 
90
 
 
91
  dash::impl::UpdateDrawSeparators(GetList());
 
92
 
 
93
  EXPECT_TRUE(groups_vector[0]->draw_separator);
 
94
  EXPECT_TRUE(groups_vector[1]->draw_separator);
 
95
  EXPECT_FALSE(groups_vector[2]->draw_separator);
 
96
}
 
97
 
 
98
TEST_F(TestPlacesGroupImpl, TestUpdateDrawSeparatorsLastTwoInvisible)
 
99
{
 
100
  groups_vector[0]->SetVisible(true);
 
101
  groups_vector[1]->SetVisible(true);
 
102
  groups_vector[2]->SetVisible(false);
 
103
  groups_vector[3]->SetVisible(false);
 
104
 
 
105
  dash::impl::UpdateDrawSeparators(GetList());
 
106
 
 
107
  EXPECT_TRUE(groups_vector[0]->draw_separator);
 
108
  EXPECT_FALSE(groups_vector[1]->draw_separator);
 
109
}
 
110
 
 
111
TEST_F(TestPlacesGroupImpl, TestUpdateDrawSeparators)
 
112
{
 
113
  groups_vector[0]->SetVisible(true);
 
114
  groups_vector[1]->SetVisible(false);
 
115
  groups_vector[2]->SetVisible(false);
 
116
  groups_vector[3]->SetVisible(true);
 
117
 
 
118
  dash::impl::UpdateDrawSeparators(GetList());
 
119
 
 
120
  EXPECT_TRUE(groups_vector[0]->draw_separator);
 
121
  EXPECT_FALSE(groups_vector[3]->draw_separator);
 
122
}
 
123
 
 
124
}
 
125