~saviq/unity/phablet-mods.bump-release

« back to all changes in this revision

Viewing changes to tests/test_switcher_controller.h

  • 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
#ifndef TEST_SWITCHER_CONTROLLER_H
 
22
#define TEST_SWITCHER_CONTROLLER_H
 
23
 
 
24
#include <NuxCore/AnimationController.h>
 
25
#include <gmock/gmock.h>
 
26
#include <chrono>
 
27
 
 
28
#include "test_utils.h"
 
29
#include "DesktopLauncherIcon.h"
 
30
#include "SimpleLauncherIcon.h"
 
31
#include "SwitcherController.h"
 
32
#include "SwitcherView.h"
 
33
#include "TimeUtil.h"
 
34
#include "unity-shared/UnitySettings.h"
 
35
#include "mock-base-window.h"
 
36
 
 
37
using namespace std::chrono;
 
38
 
 
39
typedef std::chrono::high_resolution_clock Clock;
 
40
 
 
41
#ifdef ENABLE_DELAYED_TWO_PHASE_CONSTRUCTION_TESTS
 
42
unsigned int DEFAULT_LAZY_CONSTRUCT_TIMEOUT = 20;
 
43
#endif
 
44
 
 
45
const unsigned FADE_DURATION = 80 * 1000; // in microseconds
 
46
const unsigned TICK_DURATION = 10 * 1000;
 
47
 
 
48
/**
 
49
 * A fake ApplicationWindow for verifying selection of the switcher.
 
50
 */
 
51
class FakeApplicationWindow : public unity::ApplicationWindow
 
52
{
 
53
public:
 
54
  FakeApplicationWindow(Window xid);
 
55
 
 
56
  std::string title() const;
 
57
  virtual std::string icon() const;
 
58
  virtual std::string type() const;
 
59
 
 
60
  virtual Window window_id() const;
 
61
  virtual int monitor() const;
 
62
  virtual unity::ApplicationPtr application() const;
 
63
  virtual bool Focus() const;
 
64
  virtual void Quit() const;
 
65
private:
 
66
  Window xid_;
 
67
};
 
68
 
 
69
/**
 
70
 * A fake LauncherIcon for verifying selection operations of the switcher.
 
71
 */
 
72
class FakeLauncherIcon : public unity::launcher::SimpleLauncherIcon
 
73
{
 
74
public:
 
75
  FakeLauncherIcon(std::string const& app_name, unsigned priority);
 
76
 
 
77
  unity::WindowList Windows();
 
78
  unsigned long long SwitcherPriority();
 
79
 
 
80
private:
 
81
  unsigned   priority_;
 
82
  unity::WindowList window_list;
 
83
};
 
84
 
 
85
 
 
86
/**
 
87
 * The base test fixture for verifying the Switcher interface.
 
88
 */
 
89
class TestSwitcherController : public testing::Test
 
90
{
 
91
protected:
 
92
  TestSwitcherController();
 
93
 
 
94
  // required to create hidden secret global variables before test objects
 
95
  unity::Settings unity_settings_;
 
96
 
 
97
  nux::animation::TickSource tick_source_;
 
98
  nux::animation::AnimationController animation_controller_;
 
99
  unity::testmocks::MockBaseWindow::Ptr mock_window_;
 
100
  unity::switcher::Controller::Ptr controller_;
 
101
  std::vector<unity::launcher::AbstractLauncherIcon::Ptr> icons_;
 
102
};
 
103
 
 
104
#endif // TEST_SWITCHER_CONTROLLER_H