aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/integtests/platform
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/integtests/platform')
-rw-r--r--src/test/integtests/platform/MSWindowsClipboardTests.cpp6
-rw-r--r--src/test/integtests/platform/MSWindowsKeyStateTests.cpp16
-rw-r--r--src/test/integtests/platform/OSXClipboardTests.cpp56
-rw-r--r--src/test/integtests/platform/OSXScreenTests.cpp4
-rw-r--r--src/test/integtests/platform/XWindowsClipboardTests.cpp44
-rw-r--r--src/test/integtests/platform/XWindowsKeyStateTests.cpp2
-rw-r--r--src/test/integtests/platform/XWindowsScreenSaverTests.cpp8
-rw-r--r--src/test/integtests/platform/XWindowsScreenTests.cpp8
8 files changed, 75 insertions, 69 deletions
diff --git a/src/test/integtests/platform/MSWindowsClipboardTests.cpp b/src/test/integtests/platform/MSWindowsClipboardTests.cpp
index f9d09d1..edf5a97 100644
--- a/src/test/integtests/platform/MSWindowsClipboardTests.cpp
+++ b/src/test/integtests/platform/MSWindowsClipboardTests.cpp
@@ -2,11 +2,11 @@
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2011 Nick Bolton
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -36,7 +36,7 @@ protected:
}
private:
- void emptyClipboard()
+ void emptyClipboard()
{
MSWindowsClipboard clipboard(NULL);
clipboard.open(0);
diff --git a/src/test/integtests/platform/MSWindowsKeyStateTests.cpp b/src/test/integtests/platform/MSWindowsKeyStateTests.cpp
index 9373d14..6f6edf5 100644
--- a/src/test/integtests/platform/MSWindowsKeyStateTests.cpp
+++ b/src/test/integtests/platform/MSWindowsKeyStateTests.cpp
@@ -2,11 +2,11 @@
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2011 Nick Bolton
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -16,7 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#define TEST_ENV
+#define BARRIER_TEST_ENV
#include "test/mock/barrier/MockEventQueue.h"
#include "test/mock/barrier/MockKeyMap.h"
@@ -24,7 +24,6 @@
#include "platform/MSWindowsDesks.h"
#include "platform/MSWindowsScreen.h"
#include "platform/MSWindowsScreenSaver.h"
-#include "base/TMethodJob.h"
#include "test/global/gtest.h"
#include "test/global/gmock.h"
@@ -50,10 +49,7 @@ protected:
MSWindowsDesks* newDesks(IEventQueue* eventQueue)
{
- return new MSWindowsDesks(
- true, false, m_screensaver, eventQueue,
- new TMethodJob<MSWindowsKeyStateTests>(
- this, &MSWindowsKeyStateTests::updateKeysCB), false);
+ return new MSWindowsDesks(true, false, m_screensaver, eventQueue, [](){}, false);
}
void* getEventTarget() const
@@ -62,9 +58,7 @@ protected:
}
private:
- void updateKeysCB(void*) { }
IScreenSaver* m_screensaver;
- MSWindowsHook m_hook;
};
TEST_F(MSWindowsKeyStateTests, disable_eventQueueNotUsed)
@@ -73,7 +67,7 @@ TEST_F(MSWindowsKeyStateTests, disable_eventQueueNotUsed)
MSWindowsDesks* desks = newDesks(&eventQueue);
MockKeyMap keyMap;
MSWindowsKeyState keyState(desks, getEventTarget(), &eventQueue, keyMap);
-
+
EXPECT_CALL(eventQueue, removeHandler(_, _)).Times(0);
keyState.disable();
diff --git a/src/test/integtests/platform/OSXClipboardTests.cpp b/src/test/integtests/platform/OSXClipboardTests.cpp
index 45b73bd..093c738 100644
--- a/src/test/integtests/platform/OSXClipboardTests.cpp
+++ b/src/test/integtests/platform/OSXClipboardTests.cpp
@@ -2,11 +2,11 @@
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2011 Nick Bolton
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -25,9 +25,9 @@ TEST(OSXClipboardTests, empty_openCalled_returnsTrue)
{
OSXClipboard clipboard;
clipboard.open(0);
-
+
bool actual = clipboard.empty();
-
+
EXPECT_EQ(true, actual);
}
@@ -36,9 +36,9 @@ TEST(OSXClipboardTests, empty_singleFormat_hasReturnsFalse)
OSXClipboard clipboard;
clipboard.open(0);
clipboard.add(OSXClipboard::kText, "barrier rocks!");
-
+
clipboard.empty();
-
+
bool actual = clipboard.has(OSXClipboard::kText);
EXPECT_EQ(false, actual);
}
@@ -47,9 +47,9 @@ TEST(OSXClipboardTests, add_newValue_valueWasStored)
{
OSXClipboard clipboard;
clipboard.open(0);
-
+
clipboard.add(IClipboard::kText, "barrier rocks!");
-
+
String actual = clipboard.get(IClipboard::kText);
EXPECT_EQ("barrier rocks!", actual);
}
@@ -58,10 +58,10 @@ TEST(OSXClipboardTests, add_replaceValue_valueWasReplaced)
{
OSXClipboard clipboard;
clipboard.open(0);
-
+
clipboard.add(IClipboard::kText, "barrier rocks!");
clipboard.add(IClipboard::kText, "maxivista sucks"); // haha, just kidding.
-
+
String actual = clipboard.get(IClipboard::kText);
EXPECT_EQ("maxivista sucks", actual);
}
@@ -69,18 +69,18 @@ TEST(OSXClipboardTests, add_replaceValue_valueWasReplaced)
TEST(OSXClipboardTests, open_timeIsZero_returnsTrue)
{
OSXClipboard clipboard;
-
+
bool actual = clipboard.open(0);
-
+
EXPECT_EQ(true, actual);
}
TEST(OSXClipboardTests, open_timeIsOne_returnsTrue)
{
OSXClipboard clipboard;
-
+
bool actual = clipboard.open(1);
-
+
EXPECT_EQ(true, actual);
}
@@ -88,9 +88,9 @@ TEST(OSXClipboardTests, close_isOpen_noErrors)
{
OSXClipboard clipboard;
clipboard.open(0);
-
+
clipboard.close();
-
+
// can't assert anything
}
@@ -98,9 +98,9 @@ TEST(OSXClipboardTests, getTime_openWithNoEmpty_returnsOne)
{
OSXClipboard clipboard;
clipboard.open(1);
-
+
OSXClipboard::Time actual = clipboard.getTime();
-
+
// this behavior is different to that of Clipboard which only
// returns the value passed into open(t) after empty() is called.
EXPECT_EQ((UInt32)1, actual);
@@ -111,9 +111,9 @@ TEST(OSXClipboardTests, getTime_openAndEmpty_returnsOne)
OSXClipboard clipboard;
clipboard.open(1);
clipboard.empty();
-
+
OSXClipboard::Time actual = clipboard.getTime();
-
+
EXPECT_EQ((UInt32)1, actual);
}
@@ -123,9 +123,9 @@ TEST(OSXClipboardTests, has_withFormatAdded_returnsTrue)
clipboard.open(0);
clipboard.empty();
clipboard.add(IClipboard::kText, "barrier rocks!");
-
+
bool actual = clipboard.has(IClipboard::kText);
-
+
EXPECT_EQ(true, actual);
}
@@ -134,9 +134,9 @@ TEST(OSXClipboardTests, has_withNoFormats_returnsFalse)
OSXClipboard clipboard;
clipboard.open(0);
clipboard.empty();
-
+
bool actual = clipboard.has(IClipboard::kText);
-
+
EXPECT_EQ(false, actual);
}
@@ -145,9 +145,9 @@ TEST(OSXClipboardTests, get_withNoFormats_returnsEmpty)
OSXClipboard clipboard;
clipboard.open(0);
clipboard.empty();
-
+
String actual = clipboard.get(IClipboard::kText);
-
+
EXPECT_EQ("", actual);
}
@@ -157,8 +157,8 @@ TEST(OSXClipboardTests, get_withFormatAdded_returnsExpected)
clipboard.open(0);
clipboard.empty();
clipboard.add(IClipboard::kText, "barrier rocks!");
-
+
String actual = clipboard.get(IClipboard::kText);
-
+
EXPECT_EQ("barrier rocks!", actual);
}
diff --git a/src/test/integtests/platform/OSXScreenTests.cpp b/src/test/integtests/platform/OSXScreenTests.cpp
index 96beb4d..390e22f 100644
--- a/src/test/integtests/platform/OSXScreenTests.cpp
+++ b/src/test/integtests/platform/OSXScreenTests.cpp
@@ -1,11 +1,11 @@
/*
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
diff --git a/src/test/integtests/platform/XWindowsClipboardTests.cpp b/src/test/integtests/platform/XWindowsClipboardTests.cpp
index 652ee5e..52eacda 100644
--- a/src/test/integtests/platform/XWindowsClipboardTests.cpp
+++ b/src/test/integtests/platform/XWindowsClipboardTests.cpp
@@ -2,11 +2,11 @@
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2011 Nick Bolton
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -33,12 +33,12 @@ protected:
m_display = XOpenDisplay(NULL);
int screen = DefaultScreen(m_display);
Window root = XRootWindow(m_display, screen);
-
+
XSetWindowAttributes attr;
attr.do_not_propagate_mask = 0;
attr.override_redirect = True;
attr.cursor = Cursor();
-
+
m_window = XCreateWindow(
m_display, root, 0, 0, 1, 1, 0, 0,
InputOnly, CopyFromParent, 0, &attr);
@@ -68,9 +68,9 @@ protected:
TEST_F(CXWindowsClipboardTests, empty_openCalled_returnsTrue)
{
CXWindowsClipboard clipboard = createClipboard();
-
+
bool actual = clipboard.empty();
-
+
EXPECT_EQ(true, actual);
}
@@ -78,9 +78,9 @@ TEST_F(CXWindowsClipboardTests, empty_singleFormat_hasReturnsFalse)
{
CXWindowsClipboard clipboard = createClipboard();
clipboard.add(CXWindowsClipboard::kText, "barrier rocks!");
-
+
clipboard.empty();
-
+
bool actual = clipboard.has(CXWindowsClipboard::kText);
EXPECT_FALSE(actual);
}
@@ -88,9 +88,9 @@ TEST_F(CXWindowsClipboardTests, empty_singleFormat_hasReturnsFalse)
TEST_F(CXWindowsClipboardTests, add_newValue_valueWasStored)
{
CXWindowsClipboard clipboard = createClipboard();
-
+
clipboard.add(IClipboard::kText, "barrier rocks!");
-
+
String actual = clipboard.get(IClipboard::kText);
EXPECT_EQ("barrier rocks!", actual);
}
@@ -98,10 +98,10 @@ TEST_F(CXWindowsClipboardTests, add_newValue_valueWasStored)
TEST_F(CXWindowsClipboardTests, add_replaceValue_valueWasReplaced)
{
CXWindowsClipboard clipboard = createClipboard();
-
+
clipboard.add(IClipboard::kText, "barrier rocks!");
clipboard.add(IClipboard::kText, "maxivista sucks"); // haha, just kidding.
-
+
String actual = clipboard.get(IClipboard::kText);
EXPECT_EQ("maxivista sucks", actual);
}
@@ -109,10 +109,10 @@ TEST_F(CXWindowsClipboardTests, add_replaceValue_valueWasReplaced)
TEST_F(CXWindowsClipboardTests, close_isOpen_noErrors)
{
CXWindowsClipboard clipboard = createClipboard();
-
+
// clipboard opened in createClipboard()
clipboard.close();
-
+
// can't assert anything
}
@@ -120,27 +120,27 @@ TEST_F(CXWindowsClipboardTests, has_withFormatAdded_returnsTrue)
{
CXWindowsClipboard clipboard = createClipboard();
clipboard.add(IClipboard::kText, "barrier rocks!");
-
+
bool actual = clipboard.has(IClipboard::kText);
-
+
EXPECT_EQ(true, actual);
}
TEST_F(CXWindowsClipboardTests, has_withNoFormats_returnsFalse)
{
CXWindowsClipboard clipboard = createClipboard();
-
+
bool actual = clipboard.has(IClipboard::kText);
-
+
EXPECT_FALSE(actual);
}
TEST_F(CXWindowsClipboardTests, get_withNoFormats_returnsEmpty)
{
CXWindowsClipboard clipboard = createClipboard();
-
+
String actual = clipboard.get(IClipboard::kText);
-
+
EXPECT_EQ("", actual);
}
@@ -148,9 +148,9 @@ TEST_F(CXWindowsClipboardTests, get_withFormatAdded_returnsExpected)
{
CXWindowsClipboard clipboard = createClipboard();
clipboard.add(IClipboard::kText, "barrier rocks!");
-
+
String actual = clipboard.get(IClipboard::kText);
-
+
EXPECT_EQ("barrier rocks!", actual);
}
diff --git a/src/test/integtests/platform/XWindowsKeyStateTests.cpp b/src/test/integtests/platform/XWindowsKeyStateTests.cpp
index 9f6716d..28d090f 100644
--- a/src/test/integtests/platform/XWindowsKeyStateTests.cpp
+++ b/src/test/integtests/platform/XWindowsKeyStateTests.cpp
@@ -16,7 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#define TEST_ENV
+#define BARRIER_TEST_ENV
#include "test/mock/barrier/MockKeyMap.h"
#include "test/mock/barrier/MockEventQueue.h"
diff --git a/src/test/integtests/platform/XWindowsScreenSaverTests.cpp b/src/test/integtests/platform/XWindowsScreenSaverTests.cpp
index c6a2710..a3af21d 100644
--- a/src/test/integtests/platform/XWindowsScreenSaverTests.cpp
+++ b/src/test/integtests/platform/XWindowsScreenSaverTests.cpp
@@ -23,6 +23,7 @@
#include "platform/XWindowsScreenSaver.h"
#include "test/global/gtest.h"
+#include <cstdlib>
#include <X11/Xlib.h>
using ::testing::_;
@@ -30,7 +31,12 @@ using ::testing::_;
// TODO: not working on build machine for some reason
TEST(CXWindowsScreenSaverTests, activate_defaultScreen_todo)
{
- Display* display = XOpenDisplay(":0.0");
+ const char* displayName = std::getenv("DISPLAY");
+ if (displayName == NULL) {
+ displayName = ":0.0";
+ }
+
+ Display* display = XOpenDisplay(displayName);
Window window = DefaultRootWindow(display);
MockEventQueue eventQueue;
EXPECT_CALL(eventQueue, removeHandler(_, _)).Times(1);
diff --git a/src/test/integtests/platform/XWindowsScreenTests.cpp b/src/test/integtests/platform/XWindowsScreenTests.cpp
index d8f75e1..53f113e 100644
--- a/src/test/integtests/platform/XWindowsScreenTests.cpp
+++ b/src/test/integtests/platform/XWindowsScreenTests.cpp
@@ -20,16 +20,22 @@
#include "platform/XWindowsScreen.h"
#include "test/global/gtest.h"
+#include <cstdlib>
using ::testing::_;
TEST(CXWindowsScreenTests, fakeMouseMove_nonPrimary_getCursorPosValuesCorrect)
{
+ const char* displayName = std::getenv("DISPLAY");
+ if (displayName == NULL) {
+ displayName = ":0.0";
+ }
+
MockEventQueue eventQueue;
EXPECT_CALL(eventQueue, adoptHandler(_, _, _)).Times(2);
EXPECT_CALL(eventQueue, adoptBuffer(_)).Times(2);
EXPECT_CALL(eventQueue, removeHandler(_, _)).Times(2);
- XWindowsScreen screen(new XWindowsImpl(), ":0.0", false, false, 0, &eventQueue);
+ XWindowsScreen screen(new XWindowsImpl(), displayName, false, false, 0, &eventQueue);
screen.fakeMouseMove(10, 20);