1
// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
3
* Copyright (C) 2012 Canonical Ltd
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.
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.
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/>.
17
* Authored by: Andrea Azzarone <andrea.azzarone@canonical.com>
20
#include <gmock/gmock.h>
21
using namespace testing;
23
#include "XdndStartStopNotifierImp.h"
27
//#include <X11/extensions/XTest.h>
29
#include "unity-shared/WindowManager.h"
30
#include "test_utils.h"
34
struct TestXdndStartStopNotifierImp : public Test {
35
TestXdndStartStopNotifierImp()
36
: display_(nux::GetGraphicsDisplay()->GetX11Display())
37
, selection_(XInternAtom(display_, "XdndSelection", false))
39
Window root = DefaultRootWindow(display_);
40
owner_= XCreateSimpleWindow(display_, root, -1000, -1000, 10, 10, 0, 0, 0);
47
unity::XdndStartStopNotifierImp xdnd_start_stop_notifier;
50
TEST_F(TestXdndStartStopNotifierImp, DISABLED_SignalStarted)
52
bool signal_received = false;
53
xdnd_start_stop_notifier.started.connect([&](){
54
signal_received = true;
57
XSetSelectionOwner(display_, selection_, owner_, CurrentTime);
58
//XTestFakeButtonEvent(display_, 1, True, CurrentTime);
59
auto& wm = unity::WindowManager::Default();
60
wm.window_mapped.emit(0);
62
Utils::WaitUntil(signal_received);
63
//XTestFakeButtonEvent(display_, 1, False, CurrentTime);
66
TEST_F(TestXdndStartStopNotifierImp, DISABLED_SignalFinished)
68
bool signal_received = false;
69
xdnd_start_stop_notifier.finished.connect([&](){
70
signal_received = true;
73
XSetSelectionOwner(display_, selection_, owner_, CurrentTime);
74
//XTestFakeButtonEvent(display_, 1, True, CurrentTime);
75
auto& wm = unity::WindowManager::Default();
76
wm.window_mapped.emit(0);
78
Utils::WaitForTimeoutMSec(500);
80
XSetSelectionOwner(display_, selection_, None, CurrentTime);
81
//XTestFakeButtonEvent(display_, 1, False, CurrentTime);
82
wm.window_unmapped.emit(0);
84
Utils::WaitUntil(signal_received);
87
TEST_F(TestXdndStartStopNotifierImp, DISABLED_SignalFinished_QT)
89
bool signal_received = false;
90
xdnd_start_stop_notifier.finished.connect([&](){
91
signal_received = true;
94
XSetSelectionOwner(display_, selection_, owner_, CurrentTime);
95
//XTestFakeButtonEvent(display_, 1, True, CurrentTime);
96
auto& wm = unity::WindowManager::Default();
97
wm.window_mapped.emit(0);
99
Utils::WaitForTimeoutMSec(500);
101
//XTestFakeButtonEvent(display_, 1, False, CurrentTime);
102
wm.window_unmapped.emit(0);
104
Utils::WaitUntil(signal_received);