Bazaar: GoogleTestUIExample now shows how to simulate click and mock action.

git-svn-id: svn://ultimatepp.org/upp/trunk@14992 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
klugier 2020-09-05 23:56:21 +00:00
parent 5f3d6509e1
commit e39620c940
4 changed files with 33 additions and 15 deletions

View file

@ -2,25 +2,38 @@
#include "AppWindow.h"
#include <plugin/gtest/gtest.h>
#include <plugin/gmock/gmock.h>
#include <memory>
using namespace Upp;
class AppWindowMock final : public AppWindow {
public:
MOCK_METHOD(void, OnButtonClick, (), (override));
};
class AppWindowTest : public testing::Test
{
public:
protected:
AppWindowTest()
: windowRect(0, 0, 200, 200)
{}
virtual void SetUp() override
void SetUp() override
{
window = MakeOne<AppWindow>();
window = MakeOne<AppWindowMock>();
}
public:
One<AppWindow> window;
void clickButton()
{
EXPECT_CALL(*window.Get(), OnButtonClick());
window->button.LeftDown(Point(), 0);
window->button.LeftUp(Point(), 0);
}
protected:
One<AppWindowMock> window;
const Rect windowRect;
};
@ -52,4 +65,9 @@ TEST_F(AppWindowTest, ApperanceTest)
EXPECT_EQ(img, id);
}
TEST_F(AppWindowTest, ButtonCanBeClick)
{
clickButton();
}
#endif