2919.3.68
by Marco Trevisan (Treviño)
TestShortcutCompizModeller: added tests to verify the compiz modeller |
1 |
/*
|
2 |
* Copyright 2013 Canonical Ltd.
|
|
3 |
*
|
|
4 |
* This program is free software: you can redistribute it and/or modify it
|
|
5 |
* under the terms of the GNU General Public License version 3, as published
|
|
6 |
* 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 GNU General Public License for more details.
|
|
12 |
*
|
|
13 |
* You should have received a copy of the GNU General Public License
|
|
14 |
* version 3 along with this program. If not, see
|
|
15 |
* <http://www.gnu.org/licenses/>
|
|
16 |
*
|
|
17 |
* Authored by: Marco Trevisan <marco.trevisan@canonical.com>
|
|
18 |
*/
|
|
19 |
||
20 |
#include <gmock/gmock.h> |
|
21 |
using namespace testing; |
|
22 |
||
23 |
#include "CompizShortcutModeller.h" |
|
3566.3.28
by Marco Trevisan (Treviño)
tests: use testwrapper::StandaloneWM everywhere to avoid breaking other tests |
24 |
#include "test_standalone_wm.h" |
2919.3.68
by Marco Trevisan (Treviño)
TestShortcutCompizModeller: added tests to verify the compiz modeller |
25 |
using namespace unity; |
26 |
using namespace unity::shortcut; |
|
27 |
||
28 |
namespace
|
|
29 |
{
|
|
30 |
||
31 |
struct TestShortcutCompizModeller : Test |
|
32 |
{
|
|
33 |
TestShortcutCompizModeller() |
|
3566.3.28
by Marco Trevisan (Treviño)
tests: use testwrapper::StandaloneWM everywhere to avoid breaking other tests |
34 |
: modeller(std::make_shared<CompizModeller>()) |
2919.3.68
by Marco Trevisan (Treviño)
TestShortcutCompizModeller: added tests to verify the compiz modeller |
35 |
{
|
36 |
WM->SetViewportSize(2, 2); |
|
37 |
}
|
|
38 |
||
39 |
void AssertHasWorkspaces() |
|
40 |
{
|
|
41 |
auto const& cats = modeller->GetCurrentModel()->categories(); |
|
42 |
auto it = cats.begin(); |
|
3064.2.2
by Marco Trevisan (Treviño)
TestShortcutCompizModeller: remove the i18n bits |
43 |
ASSERT_EQ(it, std::find(cats.begin(), cats.end(), "Launcher")); |
44 |
ASSERT_EQ(it = std::next(it), std::find(cats.begin(), cats.end(), "Dash")); |
|
45 |
ASSERT_EQ(it = std::next(it), std::find(cats.begin(), cats.end(), "HUD & Menu Bar")); |
|
46 |
ASSERT_EQ(it = std::next(it), std::find(cats.begin(), cats.end(), "Switching")); |
|
47 |
ASSERT_EQ(it = std::next(it), std::find(cats.begin(), cats.end(), "Workspaces")); |
|
48 |
ASSERT_EQ(it = std::next(it), std::find(cats.begin(), cats.end(), "Windows")); |
|
2919.3.68
by Marco Trevisan (Treviño)
TestShortcutCompizModeller: added tests to verify the compiz modeller |
49 |
ASSERT_EQ(std::next(it), cats.end()); |
50 |
}
|
|
51 |
||
52 |
void AssertHasNoWorkspaces() |
|
53 |
{
|
|
54 |
auto const& cats = modeller->GetCurrentModel()->categories(); |
|
55 |
auto it = cats.begin(); |
|
3064.2.2
by Marco Trevisan (Treviño)
TestShortcutCompizModeller: remove the i18n bits |
56 |
ASSERT_EQ(it, std::find(cats.begin(), cats.end(), "Launcher")); |
57 |
ASSERT_EQ(it = std::next(it), std::find(cats.begin(), cats.end(), "HUD & Menu Bar")); |
|
58 |
ASSERT_EQ(it = std::next(it), std::find(cats.begin(), cats.end(), "Switching")); |
|
59 |
ASSERT_EQ(it = std::next(it), std::find(cats.begin(), cats.end(), "Dash")); |
|
60 |
ASSERT_EQ(it = std::next(it), std::find(cats.begin(), cats.end(), "Windows")); |
|
2919.3.68
by Marco Trevisan (Treviño)
TestShortcutCompizModeller: added tests to verify the compiz modeller |
61 |
ASSERT_EQ(std::next(it), cats.end()); |
62 |
ASSERT_EQ(std::find(cats.begin(), cats.end(), "Workspaces"), cats.end()); |
|
63 |
}
|
|
64 |
||
3566.3.28
by Marco Trevisan (Treviño)
tests: use testwrapper::StandaloneWM everywhere to avoid breaking other tests |
65 |
testwrapper::StandaloneWM WM; |
2919.3.68
by Marco Trevisan (Treviño)
TestShortcutCompizModeller: added tests to verify the compiz modeller |
66 |
AbstractModeller::Ptr modeller; |
67 |
};
|
|
68 |
||
69 |
TEST_F(TestShortcutCompizModeller, Construction) |
|
70 |
{
|
|
71 |
EXPECT_NE(modeller->GetCurrentModel(), nullptr); |
|
72 |
}
|
|
73 |
||
74 |
TEST_F(TestShortcutCompizModeller, ConstructionWithWSEnabled) |
|
75 |
{
|
|
76 |
AssertHasWorkspaces(); |
|
77 |
}
|
|
78 |
||
79 |
TEST_F(TestShortcutCompizModeller, ConstructionWithWSDisabled) |
|
80 |
{
|
|
81 |
WM->SetViewportSize(1, 1); |
|
82 |
modeller = std::make_shared<CompizModeller>(); |
|
83 |
AssertHasNoWorkspaces(); |
|
84 |
}
|
|
85 |
||
86 |
TEST_F(TestShortcutCompizModeller, WorkspacesEnabled) |
|
87 |
{
|
|
88 |
AssertHasWorkspaces(); |
|
89 |
bool changed = false; |
|
90 |
modeller->model_changed.connect([&changed](Model::Ptr const&) {changed = true;}); |
|
91 |
||
92 |
WM->SetViewportSize(1, 1); |
|
93 |
AssertHasNoWorkspaces(); |
|
94 |
EXPECT_TRUE(changed); |
|
95 |
}
|
|
96 |
||
97 |
TEST_F(TestShortcutCompizModeller, WorkspacesDisabled) |
|
98 |
{
|
|
99 |
WM->SetViewportSize(1, 1); |
|
100 |
modeller = std::make_shared<CompizModeller>(); |
|
101 |
AssertHasNoWorkspaces(); |
|
102 |
||
103 |
bool changed = false; |
|
104 |
modeller->model_changed.connect([&changed](Model::Ptr const&) {changed = true;}); |
|
105 |
||
106 |
WM->SetViewportSize(2, 2); |
|
107 |
AssertHasWorkspaces(); |
|
108 |
EXPECT_TRUE(changed); |
|
109 |
}
|
|
110 |
||
3410.3.2
by Stephen M. Webb
added test case, synch with trunk |
111 |
|
3410.3.4
by Stephen M. Webb
reformatted DashHintsContains function for clarity |
112 |
bool DashHintsContains(std::list<AbstractHint::Ptr> const& hints, |
3410.3.3
by Stephen M. Webb
fixed new test |
113 |
std::string const& s) |
3410.3.2
by Stephen M. Webb
added test case, synch with trunk |
114 |
{
|
3410.3.4
by Stephen M. Webb
reformatted DashHintsContains function for clarity |
115 |
auto match_descriptions = [s](AbstractHint::Ptr const& hint) { |
3410.3.3
by Stephen M. Webb
fixed new test |
116 |
return hint->description.Get().find(s) != std::string::npos; |
3410.3.4
by Stephen M. Webb
reformatted DashHintsContains function for clarity |
117 |
};
|
118 |
auto hint = std::find_if(hints.begin(), hints.end(), match_descriptions); |
|
119 |
return hint != hints.end(); |
|
3410.3.2
by Stephen M. Webb
added test case, synch with trunk |
120 |
}
|
121 |
||
122 |
TEST_F(TestShortcutCompizModeller, BasicLensHintsArePresent) |
|
123 |
{
|
|
3410.3.3
by Stephen M. Webb
fixed new test |
124 |
auto const& dash_hints = modeller->GetCurrentModel()->hints().at("Dash"); |
125 |
EXPECT_TRUE(DashHintsContains(dash_hints, "App Lens")); |
|
3410.3.5
by Stephen M. Webb
Fixed name of Files Lens |
126 |
EXPECT_TRUE(DashHintsContains(dash_hints, "Files Lens")); |
3410.3.3
by Stephen M. Webb
fixed new test |
127 |
EXPECT_TRUE(DashHintsContains(dash_hints, "Music Lens")); |
128 |
EXPECT_TRUE(DashHintsContains(dash_hints, "Photo Lens")); |
|
129 |
EXPECT_TRUE(DashHintsContains(dash_hints, "Video Lens")); |
|
3410.3.2
by Stephen M. Webb
added test case, synch with trunk |
130 |
}
|
131 |
||
2919.3.68
by Marco Trevisan (Treviño)
TestShortcutCompizModeller: added tests to verify the compiz modeller |
132 |
}
|