~brandontschaefer/unity/lp.1099815-fix

« back to all changes in this revision

Viewing changes to tests/test_switcher_controller_slow.cpp

  • Committer: Tarmac
  • Author(s): Brandon Schaefer
  • Date: 2013-03-21 01:41:34 UTC
  • mfrom: (3225.2.2 unity)
  • Revision ID: tarmac-20130321014134-dt3qafmrpm5560ww
Moved slow unit tests in switcher controller over to test-gtest-slow.

Approved by PS Jenkins bot, Marco Trevisan (Treviño).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright 2012-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 (Treviño) <3v1n0@ubuntu.com>
 
18
 *
 
19
 */
 
20
 
 
21
 
 
22
#include "test_switcher_controller.h"
 
23
 
 
24
using namespace testing;
 
25
using namespace unity;
 
26
using namespace unity::switcher;
 
27
using namespace std::chrono;
 
28
 
 
29
TEST_F(TestSwitcherController, InitialDetailTimeout)
 
30
{
 
31
  Clock::time_point start_time = Clock::now();
 
32
  static const int initial_details_timeout = 500;
 
33
  static const int details_timeout = 10 * initial_details_timeout;
 
34
 
 
35
  controller_->detail_on_timeout = true;
 
36
  controller_->initial_detail_timeout_length = initial_details_timeout;
 
37
  controller_->detail_timeout_length = details_timeout;
 
38
 
 
39
  controller_->Show(ShowMode::ALL, SortMode::LAUNCHER_ORDER, icons_);
 
40
  Selection selection = controller_->GetCurrentSelection();
 
41
  EXPECT_EQ(selection.application_->tooltip_text(), "Second");
 
42
  EXPECT_EQ(selection.window_, 0);
 
43
 
 
44
  Utils::WaitForTimeoutMSec(initial_details_timeout * 1.1);
 
45
  selection = controller_->GetCurrentSelection();
 
46
  EXPECT_EQ(selection.application_->tooltip_text(), "Second");
 
47
  EXPECT_EQ(selection.window_, 0x0201);
 
48
 
 
49
  auto elapsed_time = Clock::now() - start_time;
 
50
  auto time_diff = duration_cast<milliseconds>(elapsed_time).count();
 
51
  EXPECT_TRUE(initial_details_timeout < time_diff);
 
52
  EXPECT_TRUE(time_diff < details_timeout);
 
53
}
 
54
 
 
55
TEST_F(TestSwitcherController, DetailTimeoutRemoval)
 
56
{
 
57
  Clock::time_point start_time = Clock::now();
 
58
  static const int details_timeout = 500;
 
59
  static const int initial_details_timeout = 10 * details_timeout;
 
60
 
 
61
  controller_->detail_on_timeout = true;
 
62
  controller_->detail_timeout_length = details_timeout;
 
63
  controller_->initial_detail_timeout_length = initial_details_timeout;
 
64
 
 
65
  controller_->Show(ShowMode::ALL, SortMode::LAUNCHER_ORDER, icons_);
 
66
  Selection selection = controller_->GetCurrentSelection();
 
67
  EXPECT_EQ(selection.application_->tooltip_text(), "Second");
 
68
  EXPECT_EQ(selection.window_, 0);
 
69
 
 
70
  controller_->Next();
 
71
  selection = controller_->GetCurrentSelection();
 
72
  EXPECT_EQ(selection.application_->tooltip_text(), "Show Desktop");
 
73
  EXPECT_EQ(selection.window_, 0);
 
74
 
 
75
  controller_->Next();
 
76
  selection = controller_->GetCurrentSelection();
 
77
  EXPECT_EQ(selection.application_->tooltip_text(), "First");
 
78
  EXPECT_EQ(selection.window_, 0);
 
79
 
 
80
  Utils::WaitForTimeoutMSec(details_timeout * 1.1);
 
81
  selection = controller_->GetCurrentSelection();
 
82
  EXPECT_EQ(selection.application_->tooltip_text(), "First");
 
83
  EXPECT_EQ(selection.window_, 0x0101);
 
84
 
 
85
 
 
86
  auto elapsed_time = Clock::now() - start_time;
 
87
  auto time_diff = duration_cast<milliseconds>(elapsed_time).count();
 
88
  EXPECT_TRUE(details_timeout < time_diff);
 
89
  EXPECT_TRUE(time_diff < initial_details_timeout);
 
90
}
 
91
 
 
92
TEST_F(TestSwitcherController, DetailTimeoutOnDetailActivate)
 
93
{
 
94
  static const int initial_details_timeout = 500;
 
95
  static const int details_timeout = 10 * initial_details_timeout;
 
96
 
 
97
  controller_->detail_on_timeout = true;
 
98
  controller_->initial_detail_timeout_length = initial_details_timeout;
 
99
  controller_->detail_timeout_length = details_timeout;
 
100
 
 
101
  controller_->Show(ShowMode::ALL, SortMode::LAUNCHER_ORDER, icons_);
 
102
  EXPECT_EQ(controller_->GetCurrentSelection().window_, 0);
 
103
 
 
104
  // Manually open-close the detail mode before that the timeout has occurred
 
105
  controller_->SetDetail(true);
 
106
  controller_->SetDetail(false);
 
107
 
 
108
  Utils::WaitForTimeoutMSec(initial_details_timeout * 1.1);
 
109
  EXPECT_EQ(controller_->GetCurrentSelection().window_, 0);
 
110
}