implemented google mock config and gave it a quick try (see: add_newValue_writeWasCalled)

This commit is contained in:
Nick Bolton
2011-05-07 02:12:09 +00:00
parent ae7a1f70e7
commit edeae477e1
10 changed files with 147 additions and 17 deletions

View File

@@ -14,10 +14,13 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
include_directories(
../../tools/gtest
../../tools/gtest/include)
add_library(gtest STATIC ../../tools/gtest/src/gtest-all.cc)
../../tools/gtest-1.6.0
../../tools/gtest-1.6.0/include
../../tools/gmock-1.6.0
../../tools/gmock-1.6.0/include)
add_library(gtest STATIC ../../tools/gtest-1.6.0/src/gtest-all.cc)
add_library(gmock STATIC ../../tools/gmock-1.6.0/src/gmock-all.cc)
add_subdirectory(integtests)
add_subdirectory(unittests)

View File

@@ -50,7 +50,8 @@ set(inc
../../lib/net
../../lib/platform
../../lib/synergy
../../../tools/gtest/include
../../../tools/gtest-1.6.0/include
../../../tools/gmock-1.6.0/include
)
if (UNIX)
@@ -62,4 +63,4 @@ endif()
include_directories(${inc})
add_executable(integtests ${src})
target_link_libraries(integtests
arch base client common io mt net platform server synergy gtest ${libs})
arch base client common io mt net platform server synergy gtest gmock ${libs})

View File

@@ -16,8 +16,9 @@
*/
#include <gtest/gtest.h>
#include <gmock/gmock.h>
#include "CMSWindowsClipboard.h"
#include "IMSWindowsClipboardFacade.h"
class CMSWindowsClipboardTests : public ::testing::Test
{
@@ -41,6 +42,12 @@ private:
}
};
class MockFacade : public IMSWindowsClipboardFacade
{
public:
MOCK_METHOD2(write, void(HANDLE, UINT));
};
TEST_F(CMSWindowsClipboardTests, emptyUnowned_openCalled_returnsTrue)
{
CMSWindowsClipboard clipboard(NULL);
@@ -84,6 +91,18 @@ TEST_F(CMSWindowsClipboardTests, add_newValue_valueWasStored)
EXPECT_EQ("synergy rocks!", actual);
}
TEST_F(CMSWindowsClipboardTests, add_newValue_writeWasCalled)
{
MockFacade facade;
EXPECT_CALL(facade, write(testing::_, testing::_));
CMSWindowsClipboard clipboard(NULL);
clipboard.setFacade(facade);
clipboard.open(0);
clipboard.add(IClipboard::kText, "synergy rocks!");
}
TEST_F(CMSWindowsClipboardTests, add_replaceValue_valueWasReplaced)
{
CMSWindowsClipboard clipboard(NULL);

View File

@@ -14,7 +14,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
set(src
../../../tools/gtest/src/gtest_main.cc
../../../tools/gtest-1.6.0/src/gtest_main.cc
synergy/CClipboardTests.cpp
)
@@ -28,7 +28,8 @@ set(inc
../../lib/net
../../lib/platform
../../lib/synergy
../../../tools/gtest/include
../../../tools/gtest-1.6.0/include
../../../tools/gmock-1.6.0/include
)
if (UNIX)
@@ -40,4 +41,4 @@ endif()
include_directories(${inc})
add_executable(unittests ${src})
target_link_libraries(unittests
arch base client common io mt net platform server synergy gtest ${libs})
arch base client common io mt net platform server synergy gtest gmock ${libs})