mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-30 06:12:20 -06:00
Bazzar: Google test example packages naming simplification.
git-svn-id: svn://ultimatepp.org/upp/trunk@14993 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
e39620c940
commit
eee1bd4e46
13 changed files with 27 additions and 28 deletions
72
bazaar/GtestUIExample/TestAppWindow.cpp
Normal file
72
bazaar/GtestUIExample/TestAppWindow.cpp
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
#ifdef flagTESTING_GTEST_UI_EXAMPLE
|
||||
|
||||
#include "AppWindow.h"
|
||||
|
||||
#include <plugin/gmock/gmock.h>
|
||||
|
||||
using namespace Upp;
|
||||
|
||||
class AppWindowMock final : public AppWindow {
|
||||
public:
|
||||
MOCK_METHOD(void, OnButtonClick, (), (override));
|
||||
};
|
||||
|
||||
class AppWindowTest : public testing::Test
|
||||
{
|
||||
protected:
|
||||
AppWindowTest()
|
||||
: windowRect(0, 0, 200, 200)
|
||||
{}
|
||||
|
||||
void SetUp() override
|
||||
{
|
||||
window = MakeOne<AppWindowMock>();
|
||||
}
|
||||
|
||||
void clickButton()
|
||||
{
|
||||
EXPECT_CALL(*window.Get(), OnButtonClick());
|
||||
|
||||
window->button.LeftDown(Point(), 0);
|
||||
window->button.LeftUp(Point(), 0);
|
||||
}
|
||||
|
||||
protected:
|
||||
One<AppWindowMock> window;
|
||||
const Rect windowRect;
|
||||
};
|
||||
|
||||
TEST_F(AppWindowTest, Initialization)
|
||||
{
|
||||
EXPECT_STREQ(L"App Window", window->GetTitle().ToStd().c_str());
|
||||
EXPECT_FALSE(window->IsMaximized());
|
||||
EXPECT_FALSE(window->IsMinimized());
|
||||
|
||||
EXPECT_EQ(windowRect, window->GetRect());
|
||||
}
|
||||
|
||||
TEST_F(AppWindowTest, ApperanceTest)
|
||||
{
|
||||
const String fileName = "MyAppWindow.png";
|
||||
|
||||
ImageDraw id(window->GetRect().Size());
|
||||
window->DrawCtrl(id);
|
||||
|
||||
PNGEncoder encoder;
|
||||
if (!FileExists(fileName)) {
|
||||
encoder.SaveFile(fileName, id);
|
||||
Cout() << "Non referal window image. Creating and failing test..\n";
|
||||
ASSERT_TRUE(false);
|
||||
return;
|
||||
}
|
||||
|
||||
auto img = StreamRaster::LoadFileAny(fileName);
|
||||
EXPECT_EQ(img, id);
|
||||
}
|
||||
|
||||
TEST_F(AppWindowTest, ButtonCanBeClick)
|
||||
{
|
||||
clickButton();
|
||||
}
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue