2
* Copyright 2012 Canonical Ltd.
4
* This program is free software: you can redistribute it and/or modify it
5
* under the terms of the GNU Lesser 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, but
9
* WITHOUT ANY WARRANTY; without even the implied warranties of
10
* MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
11
* PURPOSE. See the applicable version of the GNU Lesser General Public
12
* License for more details.
14
* You should have received a copy of both the GNU Lesser General Public
15
* License version 3 along with this program. If not, see
16
* <http://www.gnu.org/licenses/>
18
* Authored by: Andrea Azzarone <azzaronea@gmail.com>
22
#include <gtest/gtest.h>
24
#include "hud/HudPrivate.h"
25
using namespace unity::hud;
30
TEST(TestHudPrivate, RefactorTextEmpty)
32
std::vector<std::pair<std::string, bool>> temp;
34
temp = impl::RefactorText("");
35
ASSERT_EQ(temp.size(), 0);
37
temp = impl::RefactorText("Test");
38
ASSERT_EQ(temp.size(), 1);
39
EXPECT_EQ(temp[0].first, "Test");
40
EXPECT_EQ(temp[0].second, false); // True means "Full opacity", false "Half opacity"
42
temp = impl::RefactorText("<b>Test</b>");
43
ASSERT_EQ(temp.size(), 1);
44
EXPECT_EQ(temp[0].first, "Test");
45
EXPECT_EQ(temp[0].second, true);
47
temp = impl::RefactorText("Hello > <b>Test</b> World");
48
ASSERT_EQ(temp.size(), 3);
49
EXPECT_EQ(temp[0].first, "Hello > ");
50
EXPECT_EQ(temp[0].second, false);
51
EXPECT_EQ(temp[1].first, "Test");
52
EXPECT_EQ(temp[1].second, true);
53
EXPECT_EQ(temp[2].first, " World");
54
EXPECT_EQ(temp[2].second, false);
56
temp = impl::RefactorText("Open <b>Fi</b>le <b>Wit</b>h");
57
ASSERT_EQ(temp.size(), 5);
58
EXPECT_EQ(temp[0].first, "Open ");
59
EXPECT_EQ(temp[0].second, false);
60
EXPECT_EQ(temp[1].first, "Fi");
61
EXPECT_EQ(temp[1].second, true);
62
EXPECT_EQ(temp[2].first, "le ");
63
EXPECT_EQ(temp[2].second, false);
64
EXPECT_EQ(temp[3].first, "Wit");
65
EXPECT_EQ(temp[3].second, true);
66
EXPECT_EQ(temp[4].first, "h");
67
EXPECT_EQ(temp[4].second, false);
69
temp = impl::RefactorText("Open <b>File With");
70
ASSERT_EQ(temp.size(), 2);
71
EXPECT_EQ(temp[0].first, "Open ");
72
EXPECT_EQ(temp[0].second, false);
73
EXPECT_EQ(temp[1].first, "File With");
74
EXPECT_EQ(temp[1].second, true);