~dfly720/unity/fix-938353

« back to all changes in this revision

Viewing changes to tests/test_hud_private.cpp

  • Committer: Marco Mariani
  • Date: 2012-05-31 21:58:19 UTC
  • mfrom: (2341.1.38 unity)
  • Revision ID: dfly720@gmail.com-20120531215819-0er7r9qftgxqvt7a
Merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright 2012 Canonical Ltd.
 
3
 *
 
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.
 
7
 *
 
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.
 
13
 *
 
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/>
 
17
 *
 
18
 * Authored by: Andrea Azzarone <azzaronea@gmail.com>
 
19
 *
 
20
 */
 
21
 
 
22
#include <gtest/gtest.h>
 
23
 
 
24
#include "hud/HudPrivate.h"
 
25
using namespace unity::hud;
 
26
 
 
27
namespace
 
28
{
 
29
 
 
30
TEST(TestHudPrivate, RefactorTextEmpty)
 
31
{
 
32
  std::vector<std::pair<std::string, bool>> temp;
 
33
 
 
34
  temp = impl::RefactorText("");
 
35
  ASSERT_EQ(temp.size(), 0);
 
36
 
 
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"
 
41
 
 
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);
 
46
 
 
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);
 
55
 
 
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);
 
68
 
 
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);
 
75
}
 
76
 
 
77
}