Add a function to construct the GRSurface in test
This fixes the build error as the initializer list no longer work without the proper constructor for c++ class. Bug: 74397117 Test: unit tests pass Change-Id: If3ff508a1a01ad5326413dab8e05bacae8a946c8
This commit is contained in:
parent
06ccd00ef5
commit
1e10cc4297
1 changed files with 14 additions and 3 deletions
|
@ -69,6 +69,17 @@ class ScreenUITest : public testing::Test {
|
||||||
MockDrawFunctions draw_funcs_;
|
MockDrawFunctions draw_funcs_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// TODO(xunchang) Create a constructor.
|
||||||
|
static GRSurface CreateFakeGRSurface(int width, int height, int row_bytes, int pixel_bytes) {
|
||||||
|
GRSurface fake_surface;
|
||||||
|
fake_surface.width = width;
|
||||||
|
fake_surface.height = height;
|
||||||
|
fake_surface.row_bytes = row_bytes;
|
||||||
|
fake_surface.pixel_bytes = pixel_bytes;
|
||||||
|
|
||||||
|
return fake_surface;
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(ScreenUITest, StartPhoneMenuSmoke) {
|
TEST_F(ScreenUITest, StartPhoneMenuSmoke) {
|
||||||
TextMenu menu(false, 10, 20, HEADERS, ITEMS, 0, 20, draw_funcs_);
|
TextMenu menu(false, 10, 20, HEADERS, ITEMS, 0, 20, draw_funcs_);
|
||||||
ASSERT_FALSE(menu.scrollable());
|
ASSERT_FALSE(menu.scrollable());
|
||||||
|
@ -230,7 +241,7 @@ TEST_F(ScreenUITest, WearMenuSelectItemsOverflow) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ScreenUITest, GraphicMenuSelection) {
|
TEST_F(ScreenUITest, GraphicMenuSelection) {
|
||||||
GRSurface fake_surface = GRSurface{ 50, 50, 50, 1, nullptr };
|
auto fake_surface = CreateFakeGRSurface(50, 50, 50, 1);
|
||||||
std::vector<GRSurface*> items = { &fake_surface, &fake_surface, &fake_surface };
|
std::vector<GRSurface*> items = { &fake_surface, &fake_surface, &fake_surface };
|
||||||
GraphicMenu menu(&fake_surface, items, 0, draw_funcs_);
|
GraphicMenu menu(&fake_surface, items, 0, draw_funcs_);
|
||||||
|
|
||||||
|
@ -252,13 +263,13 @@ TEST_F(ScreenUITest, GraphicMenuSelection) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ScreenUITest, GraphicMenuValidate) {
|
TEST_F(ScreenUITest, GraphicMenuValidate) {
|
||||||
auto fake_surface = GRSurface{ 50, 50, 50, 1, nullptr };
|
auto fake_surface = CreateFakeGRSurface(50, 50, 50, 1);
|
||||||
std::vector<GRSurface*> items = { &fake_surface, &fake_surface, &fake_surface };
|
std::vector<GRSurface*> items = { &fake_surface, &fake_surface, &fake_surface };
|
||||||
|
|
||||||
ASSERT_TRUE(GraphicMenu::Validate(200, 200, &fake_surface, items));
|
ASSERT_TRUE(GraphicMenu::Validate(200, 200, &fake_surface, items));
|
||||||
|
|
||||||
// Menu exceeds the horizontal boundary.
|
// Menu exceeds the horizontal boundary.
|
||||||
auto wide_surface = GRSurface{ 300, 50, 300, 1, nullptr };
|
auto wide_surface = CreateFakeGRSurface(300, 50, 300, 1);
|
||||||
ASSERT_FALSE(GraphicMenu::Validate(299, 200, &wide_surface, items));
|
ASSERT_FALSE(GraphicMenu::Validate(299, 200, &wide_surface, items));
|
||||||
|
|
||||||
// Menu exceeds the vertical boundary.
|
// Menu exceeds the vertical boundary.
|
||||||
|
|
Loading…
Reference in a new issue