Back to index

unity  6.0.0
test_lensview_impl.cpp
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2012 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: Andrea Azzarone <azzaronea@gmail.com>
00017  */
00018 
00019 #include <list>
00020 #include <vector>
00021 
00022 #include <gmock/gmock.h>
00023 
00024 #include "LensViewPrivate.h"
00025 #include "AbstractPlacesGroup.h"
00026 
00027 using namespace unity;
00028 using namespace testing;
00029 
00030 namespace
00031 {
00032 
00033 const int NUM_GROUPS = 4;
00034 
00035 class TestPlacesGroupImpl : public Test
00036 {
00037 public:
00038   TestPlacesGroupImpl()
00039   {
00040     for (int i=0; i<NUM_GROUPS; ++i)
00041       groups_vector.push_back(new dash::AbstractPlacesGroup);
00042   }
00043 
00044   ~TestPlacesGroupImpl()
00045   {
00046     for (int i=0; i<NUM_GROUPS; ++i)
00047       delete groups_vector[i];
00048   }
00049 
00050   std::list<dash::AbstractPlacesGroup*> GetList()
00051   {
00052     std::list<dash::AbstractPlacesGroup*> ret;
00053     std::copy(groups_vector.begin(), groups_vector.end(), std::back_inserter(ret));
00054     return ret;
00055   }
00056 
00057   std::vector<dash::AbstractPlacesGroup*> groups_vector;
00058 };
00059 
00060 
00061 TEST_F(TestPlacesGroupImpl, TestUpdateDrawSeparatorsEmpty)
00062 {
00063   std::list<dash::AbstractPlacesGroup*> groups;
00064 
00065   // Just to make sure it doesn't crash.
00066   dash::impl::UpdateDrawSeparators(groups);
00067 }
00068 
00069 TEST_F(TestPlacesGroupImpl, TestUpdateDrawSeparatorsAllVisible)
00070 {
00071   groups_vector[0]->SetVisible(true);
00072   groups_vector[1]->SetVisible(true);
00073   groups_vector[2]->SetVisible(true);
00074   groups_vector[3]->SetVisible(true);
00075 
00076   dash::impl::UpdateDrawSeparators(GetList());
00077 
00078   EXPECT_TRUE(groups_vector[0]->draw_separator);
00079   EXPECT_TRUE(groups_vector[1]->draw_separator);
00080   EXPECT_TRUE(groups_vector[2]->draw_separator);
00081   EXPECT_FALSE(groups_vector[3]->draw_separator);
00082 }
00083 
00084 TEST_F(TestPlacesGroupImpl, TestUpdateDrawSeparatorsLastInvisible)
00085 {
00086   groups_vector[0]->SetVisible(true);
00087   groups_vector[1]->SetVisible(true);
00088   groups_vector[2]->SetVisible(true);
00089   groups_vector[3]->SetVisible(false);
00090 
00091   dash::impl::UpdateDrawSeparators(GetList());
00092 
00093   EXPECT_TRUE(groups_vector[0]->draw_separator);
00094   EXPECT_TRUE(groups_vector[1]->draw_separator);
00095   EXPECT_FALSE(groups_vector[2]->draw_separator);
00096 }
00097 
00098 TEST_F(TestPlacesGroupImpl, TestUpdateDrawSeparatorsLastTwoInvisible)
00099 {
00100   groups_vector[0]->SetVisible(true);
00101   groups_vector[1]->SetVisible(true);
00102   groups_vector[2]->SetVisible(false);
00103   groups_vector[3]->SetVisible(false);
00104 
00105   dash::impl::UpdateDrawSeparators(GetList());
00106 
00107   EXPECT_TRUE(groups_vector[0]->draw_separator);
00108   EXPECT_FALSE(groups_vector[1]->draw_separator);
00109 }
00110 
00111 TEST_F(TestPlacesGroupImpl, TestUpdateDrawSeparators)
00112 {
00113   groups_vector[0]->SetVisible(true);
00114   groups_vector[1]->SetVisible(false);
00115   groups_vector[2]->SetVisible(false);
00116   groups_vector[3]->SetVisible(true);
00117 
00118   dash::impl::UpdateDrawSeparators(GetList());
00119 
00120   EXPECT_TRUE(groups_vector[0]->draw_separator);
00121   EXPECT_FALSE(groups_vector[3]->draw_separator);
00122 }
00123 
00124 }
00125