~3v1n0/unity/light-shortcuts

« back to all changes in this revision

Viewing changes to tests/test_xdnd_start_stop_notifier_imp.cpp

  • Committer: Marco Trevisan (Treviño)
  • Date: 2013-04-26 12:41:09 UTC
  • Revision ID: mail@3v1n0.net-20130426124109-t3b2shjah2omiqa2
Unity: Remove all the views, but the Shortcuts

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
2
 
/*
3
 
* Copyright (C) 2012 Canonical Ltd
4
 
*
5
 
* This program is free software: you can redistribute it and/or modify
6
 
* it under the terms of the GNU General Public License version 3 as
7
 
* published by the Free Software Foundation.
8
 
*
9
 
* This program is distributed in the hope that it will be useful,
10
 
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 
* GNU General Public License for more details.
13
 
*
14
 
* You should have received a copy of the GNU General Public License
15
 
* along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
 
*
17
 
* Authored by: Andrea Azzarone <andrea.azzarone@canonical.com>
18
 
*/
19
 
 
20
 
#include <gmock/gmock.h>
21
 
using namespace testing;
22
 
 
23
 
#include "XdndStartStopNotifierImp.h"
24
 
 
25
 
#include <Nux/Nux.h>
26
 
#include <X11/Xlib.h>
27
 
//#include <X11/extensions/XTest.h>
28
 
 
29
 
#include "unity-shared/WindowManager.h"
30
 
#include "test_utils.h"
31
 
 
32
 
namespace {
33
 
 
34
 
struct TestXdndStartStopNotifierImp : public Test {
35
 
  TestXdndStartStopNotifierImp()
36
 
    : display_(nux::GetGraphicsDisplay()->GetX11Display())
37
 
    , selection_(XInternAtom(display_, "XdndSelection", false))
38
 
  {
39
 
    Window root = DefaultRootWindow(display_);
40
 
    owner_= XCreateSimpleWindow(display_, root, -1000, -1000, 10, 10, 0, 0, 0);
41
 
  }
42
 
 
43
 
  Display* display_;
44
 
  Atom selection_;
45
 
  Window owner_;
46
 
 
47
 
  unity::XdndStartStopNotifierImp xdnd_start_stop_notifier;
48
 
};
49
 
 
50
 
TEST_F(TestXdndStartStopNotifierImp, DISABLED_SignalStarted)
51
 
{
52
 
  bool signal_received = false;
53
 
  xdnd_start_stop_notifier.started.connect([&](){
54
 
    signal_received = true;
55
 
  });
56
 
 
57
 
  XSetSelectionOwner(display_, selection_, owner_, CurrentTime);
58
 
  //XTestFakeButtonEvent(display_, 1, True, CurrentTime);
59
 
  auto& wm = unity::WindowManager::Default();
60
 
  wm.window_mapped.emit(0);
61
 
 
62
 
  Utils::WaitUntil(signal_received);
63
 
  //XTestFakeButtonEvent(display_, 1, False, CurrentTime);
64
 
}
65
 
 
66
 
TEST_F(TestXdndStartStopNotifierImp, DISABLED_SignalFinished)
67
 
{
68
 
  bool signal_received = false;
69
 
  xdnd_start_stop_notifier.finished.connect([&](){
70
 
    signal_received = true;
71
 
  });
72
 
 
73
 
  XSetSelectionOwner(display_, selection_, owner_, CurrentTime);
74
 
  //XTestFakeButtonEvent(display_, 1, True, CurrentTime);
75
 
  auto& wm = unity::WindowManager::Default();
76
 
  wm.window_mapped.emit(0);
77
 
 
78
 
  Utils::WaitForTimeoutMSec(500);
79
 
 
80
 
  XSetSelectionOwner(display_, selection_, None, CurrentTime);
81
 
  //XTestFakeButtonEvent(display_, 1, False, CurrentTime);
82
 
  wm.window_unmapped.emit(0);
83
 
 
84
 
  Utils::WaitUntil(signal_received);
85
 
}
86
 
 
87
 
TEST_F(TestXdndStartStopNotifierImp, DISABLED_SignalFinished_QT)
88
 
{
89
 
  bool signal_received = false;
90
 
  xdnd_start_stop_notifier.finished.connect([&](){
91
 
    signal_received = true;
92
 
  });
93
 
 
94
 
  XSetSelectionOwner(display_, selection_, owner_, CurrentTime);
95
 
  //XTestFakeButtonEvent(display_, 1, True, CurrentTime);
96
 
  auto& wm = unity::WindowManager::Default();
97
 
  wm.window_mapped.emit(0);
98
 
 
99
 
  Utils::WaitForTimeoutMSec(500);
100
 
 
101
 
  //XTestFakeButtonEvent(display_, 1, False, CurrentTime);
102
 
  wm.window_unmapped.emit(0);
103
 
 
104
 
  Utils::WaitUntil(signal_received);
105
 
}
106
 
 
107
 
}