From 016842819819c9dcc4039d9b06c87e246305cfe8 Mon Sep 17 00:00:00 2001 From: Nick Bolton Date: Fri, 22 Apr 2011 20:32:29 +0000 Subject: [PATCH] created unittest dir, made test CMakeLists.txt smaller, and created first basic test for CClipboard --- cmake/CMakeLists_lib.txt | 1 - cmake/CMakeLists_test.txt | 65 ++----------------- src/unittest/synergy/CClipboardTests.cpp | 32 +++++++++ .../unittest/synergy/HelloWorldTests.cpp | 2 +- 4 files changed, 39 insertions(+), 61 deletions(-) create mode 100644 src/unittest/synergy/CClipboardTests.cpp rename lib/synergy/CProtocolUtilTest.cpp => src/unittest/synergy/HelloWorldTests.cpp (98%) diff --git a/cmake/CMakeLists_lib.txt b/cmake/CMakeLists_lib.txt index 8a48e411..4c12daa9 100644 --- a/cmake/CMakeLists_lib.txt +++ b/cmake/CMakeLists_lib.txt @@ -300,7 +300,6 @@ SET(src_lib_synergy ${root_lib}/synergy/CPacketStreamFilter.cpp ${root_lib}/synergy/CPlatformScreen.cpp ${root_lib}/synergy/CProtocolUtil.cpp - ${root_lib}/synergy/CProtocolUtilTest.cpp ${root_lib}/synergy/CScreen.cpp ${root_lib}/synergy/IClipboard.cpp ${root_lib}/synergy/IKeyState.cpp diff --git a/cmake/CMakeLists_test.txt b/cmake/CMakeLists_test.txt index 645722be..129b2cd7 100644 --- a/cmake/CMakeLists_test.txt +++ b/cmake/CMakeLists_test.txt @@ -13,66 +13,13 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -SET(root_cmd_synergyc ${root_dir}/cmd/synergyc) - -SET(src_cmd_synergyc_common - ${root_dir}/lib/synergy/CProtocolUtilTest.cpp - ${root_dir}/third_party/gtest/src/gtest-all.cc - #${root_cmd_synergyc}/synergyc.cpp -) - -SET(src_cmd_synergyc_xwindows - ${root_cmd_synergyc}/CXWindowsClientTaskBarReceiver.cpp -) - -SET(src_cmd_synergyc_mswindows - ${root_cmd_synergyc}/CMSWindowsClientTaskBarReceiver.cpp -) - -SET(inc_cmd_synergyc_mswindows - ${root_cmd_synergyc}/CMSWindowsClientTaskBarReceiver.h - ${root_cmd_synergyc}/resource.h -) - -SET(res_cmd_synergyc_mswindows - ${root_cmd_synergyc}/synergyc.ico - ${root_cmd_synergyc}/synergyc.rc - ${root_cmd_synergyc}/tb_error.ico - ${root_cmd_synergyc}/tb_idle.ico - ${root_cmd_synergyc}/tb_run.ico - ${root_cmd_synergyc}/tb_wait.ico -) - -SET(src_cmd_synergyc_carbon - ${root_cmd_synergyc}/COSXClientTaskBarReceiver.cpp -) - -SET(src_cmd_synergyc ${src_cmd_synergyc_common}) - -IF(UNIX) - - IF(APPLE) - LIST(APPEND src_cmd_synergyc ${src_cmd_synergyc_carbon}) - ELSE(APPLE) - LIST(APPEND src_cmd_synergyc ${src_cmd_synergyc_xwindows}) - ENDIF(APPLE) - -ELSE(UNIX) - - LIST(APPEND src_cmd_synergyc - ${inc_cmd_synergyc_mswindows} - ${res_cmd_synergyc_mswindows} - ${src_cmd_synergyc_mswindows} - ) - -ENDIF(UNIX) - # Include all files that have unit tests -SET(inc_dirs_tests - ${root_dir}/lib/synergy/CProtocolUtilTest.cpp +SET(tests + ${root_dir}/src/unittest/synergy/CClipboardTests.cpp + ${root_dir}/src/unittest/synergy/HelloWorldTests.cpp ) -SET(inc_dirs_test +SET(inc ${root_dir} ${root_dir}/lib ${root_dir}/lib/arch @@ -88,6 +35,6 @@ SET(inc_dirs_test ${root_dir}/third_party/gtest/include ) -INCLUDE_DIRECTORIES(${inc_dirs_test}) -ADD_EXECUTABLE(tests ${root_dir}/third_party/gtest/src/gtest_main.cc ${inc_dirs_tests}) +INCLUDE_DIRECTORIES(${inc}) +ADD_EXECUTABLE(tests ${root_dir}/third_party/gtest/src/gtest_main.cc ${tests}) TARGET_LINK_LIBRARIES(tests synergy gtest ${libs}) diff --git a/src/unittest/synergy/CClipboardTests.cpp b/src/unittest/synergy/CClipboardTests.cpp new file mode 100644 index 00000000..cc18e5c2 --- /dev/null +++ b/src/unittest/synergy/CClipboardTests.cpp @@ -0,0 +1,32 @@ +/* + * synergy -- mouse and keyboard sharing utility + * Copyright (C) 2010 Chris Schoeneman, Nick Bolton, Sorin Sbarnea + * + * 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 COPYING 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 + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include "CClipboard.h" + +TEST(CClipboardTests, getTime_defaultState_returnsZero) +{ + // arrange + CClipboard clipboard; + + // act + CClipboard::Time actual = clipboard.getTime(); + + // assert + CClipboard::Time expected(0); + EXPECT_EQ(expected, actual); +} diff --git a/lib/synergy/CProtocolUtilTest.cpp b/src/unittest/synergy/HelloWorldTests.cpp similarity index 98% rename from lib/synergy/CProtocolUtilTest.cpp rename to src/unittest/synergy/HelloWorldTests.cpp index 74c0bfc8..9bd975eb 100644 --- a/lib/synergy/CProtocolUtilTest.cpp +++ b/src/unittest/synergy/HelloWorldTests.cpp @@ -44,7 +44,7 @@ // // -TEST(ProtocolUntilTest, HelloWorld) { +TEST(HelloWorldTests, helloWorld) { EXPECT_EQ(1, 1); }