Back to index

unity  6.0.0
test_bamflaunchericon.cpp
Go to the documentation of this file.
00001 /*
00002  * Copyright 2012 Canonical Ltd.
00003  *
00004  * This program is free software: you can redistribute it and/or modify it
00005  * under the terms of the GNU General Public License version 3, as published
00006  * by the  Free Software Foundation.
00007  *
00008  * This program is distributed in the hope that it will be useful, but
00009  * WITHOUT ANY WARRANTY; without even the implied warranties of
00010  * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
00011  * PURPOSE.  See the GNU General Public License for more details.
00012  *
00013  * You should have received a copy of the GNU General Public License
00014  * version 3 along with this program.  If not, see
00015  * <http://www.gnu.org/licenses/>
00016  *
00017  * Authored by: Andrea Azzarone <azzarone@gmail.com>
00018  */
00019 
00020 #include <config.h>
00021 #include <gmock/gmock.h>
00022 
00023 #include <UnityCore/GLibWrapper.h>
00024 
00025 #include "BamfLauncherIcon.h"
00026 using namespace unity;
00027 
00028 namespace
00029 {
00030 
00031 class TestBamfLauncherIcon : public testing::Test
00032 {
00033 public:
00034   virtual void SetUp()
00035   {
00036     bamf_matcher = bamf_matcher_get_default();
00037     bamf_app = bamf_matcher_get_application_for_desktop_file(bamf_matcher,
00038                                                              BUILDDIR"/tests/data/ubuntu-software-center.desktop",
00039                                                              TRUE);
00040 
00041     usc_icon = new launcher::BamfLauncherIcon(bamf_app);
00042 
00043   }
00044 
00045   virtual void TearDown()
00046   {
00047   }
00048 
00049   glib::Object<BamfMatcher> bamf_matcher;
00050   BamfApplication* bamf_app;
00051   nux::ObjectPtr<launcher::BamfLauncherIcon> usc_icon;
00052 
00053 };
00054 
00055 TEST_F(TestBamfLauncherIcon, TestCustomBackgroundColor)
00056 {
00057   nux::Color const& color = usc_icon->BackgroundColor();
00058 
00059   EXPECT_EQ(color.red, 0xaa / 255.0f);
00060   EXPECT_EQ(color.green, 0xbb / 255.0f);
00061   EXPECT_EQ(color.blue, 0xcc / 255.0f);
00062   EXPECT_EQ(color.alpha, 0xff / 255.0f);
00063 }
00064 
00065 TEST_F(TestBamfLauncherIcon, TestColorStringConversion)
00066 {
00067   EXPECT_EQ(launcher::ColorStrToARGB("#12345678"), 0x78123456);
00068   EXPECT_EQ(launcher::ColorStrToARGB("12345678"), 0x78123456);
00069   EXPECT_EQ(launcher::ColorStrToARGB("#12345678q"), 0x0);
00070   EXPECT_EQ(launcher::ColorStrToARGB("12345678q"), 0x0);
00071   EXPECT_EQ(launcher::ColorStrToARGB("#1234567890"), 0x0);
00072   EXPECT_EQ(launcher::ColorStrToARGB("1234567890"), 0x0);
00073   EXPECT_EQ(launcher::ColorStrToARGB("#AABBCC"), 0xFFAABBCC);
00074   EXPECT_EQ(launcher::ColorStrToARGB("AABBCC"), 0xFFAABBCC);
00075   EXPECT_EQ(launcher::ColorStrToARGB("#eeddccbb"), 0xBBEEDDCC);
00076   EXPECT_EQ(launcher::ColorStrToARGB("eeddccbb"), 0xBBEEDDCC);
00077   EXPECT_EQ(launcher::ColorStrToARGB("#2040"), 0x0);
00078   EXPECT_EQ(launcher::ColorStrToARGB("2040"), 0x0);
00079   EXPECT_EQ(launcher::ColorStrToARGB("#2040809"), 0x0);
00080   EXPECT_EQ(launcher::ColorStrToARGB("2040809"), 0x0);
00081   EXPECT_EQ(launcher::ColorStrToARGB("#204080"), 0xFF204080);
00082   EXPECT_EQ(launcher::ColorStrToARGB("204080"), 0xFF204080);
00083   EXPECT_EQ(launcher::ColorStrToARGB("#blah"), 0x0);
00084   EXPECT_EQ(launcher::ColorStrToARGB("blah"), 0x0);
00085   EXPECT_EQ(launcher::ColorStrToARGB("#"), 0x0);
00086   EXPECT_EQ(launcher::ColorStrToARGB(""), 0x0);
00087   EXPECT_EQ(launcher::ColorStrToARGB("helloworld helloworld !!!!"), 0x0);
00088 }
00089 
00090 }