Back to index

unity  6.0.0
test_hud_private.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 Lesser 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, but
00009  * WITHOUT ANY WARRANTY; without even the implied warranties of
00010  * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
00011  * PURPOSE.  See the applicable version of the GNU Lesser General Public
00012  * License for more details.
00013  *
00014  * You should have received a copy of both the GNU Lesser General Public
00015  * License version 3 along with this program.  If not, see
00016  * <http://www.gnu.org/licenses/>
00017  *
00018  * Authored by: Andrea Azzarone <azzaronea@gmail.com>
00019  *
00020  */
00021 
00022 #include <gtest/gtest.h>
00023 
00024 #include "hud/HudPrivate.h"
00025 using namespace unity::hud;
00026 
00027 namespace
00028 {
00029 
00030 TEST(TestHudPrivate, RefactorTextEmpty)
00031 {
00032   std::vector<std::pair<std::string, bool>> temp;
00033 
00034   temp = impl::RefactorText("");
00035   ASSERT_EQ(temp.size(), 0);
00036 
00037   temp = impl::RefactorText("Test");
00038   ASSERT_EQ(temp.size(), 1);
00039   EXPECT_EQ(temp[0].first, "Test");
00040   EXPECT_EQ(temp[0].second, false); // True means "Full opacity", false "Half opacity"
00041 
00042   temp = impl::RefactorText("<b>Test</b>");
00043   ASSERT_EQ(temp.size(), 1);
00044   EXPECT_EQ(temp[0].first, "Test");
00045   EXPECT_EQ(temp[0].second, true);
00046 
00047   temp = impl::RefactorText("Hello > <b>Test</b> World");
00048   ASSERT_EQ(temp.size(), 3);
00049   EXPECT_EQ(temp[0].first, "Hello > ");
00050   EXPECT_EQ(temp[0].second, false);
00051   EXPECT_EQ(temp[1].first, "Test");
00052   EXPECT_EQ(temp[1].second, true);
00053   EXPECT_EQ(temp[2].first, " World");
00054   EXPECT_EQ(temp[2].second, false);
00055 
00056   temp = impl::RefactorText("Open <b>Fi</b>le <b>Wit</b>h");
00057   ASSERT_EQ(temp.size(), 5);
00058   EXPECT_EQ(temp[0].first, "Open ");
00059   EXPECT_EQ(temp[0].second, false);
00060   EXPECT_EQ(temp[1].first, "Fi");
00061   EXPECT_EQ(temp[1].second, true);
00062   EXPECT_EQ(temp[2].first, "le ");
00063   EXPECT_EQ(temp[2].second, false);
00064   EXPECT_EQ(temp[3].first, "Wit");
00065   EXPECT_EQ(temp[3].second, true);
00066   EXPECT_EQ(temp[4].first, "h");
00067   EXPECT_EQ(temp[4].second, false);
00068 
00069   temp = impl::RefactorText("Open <b>File With");
00070   ASSERT_EQ(temp.size(), 2);
00071   EXPECT_EQ(temp[0].first, "Open ");
00072   EXPECT_EQ(temp[0].second, false);
00073   EXPECT_EQ(temp[1].first, "File With");
00074   EXPECT_EQ(temp[1].second, true);
00075 }
00076 
00077 }