1 /*
2 * Copyright 2020, The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #include <getopt.h>
18 #include <gtest/gtest.h>
19 #include <iostream>
20 #include <stdio.h>
21 #include <stdlib.h>
22 #include <teeui/example/example.h>
23 #include <unistd.h>
24
25 #include "teeui_device_config.h"
26 #include <teeui/test/teeui_render_test.h>
27
28 #define TeeuiDrawLabelTextTest_DO_LOG_DEBUG
29
30 namespace teeui {
31
32 namespace test {
33
34 static constexpr const char kText12Character8Group[] =
35 "WWWWWWWWWWWW WWWWWWWWWWWW WWWWWWWWWWWW WWWWWWWWWWWW WWWWWWWWWWWW WWWWWWWWWWWW WWWWWWWWWWWW "
36 "WWWWWWWWWWWW";
37
38 static constexpr const char kText100Character1Group[] =
39 "WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW"
40 "WWWWWWWW";
41
42 class TeeuiDrawLabelTextTest : public ::testing::Test {};
43
TEST_F(TeeuiDrawLabelTextTest,Test_12_char_8_group_phys_button_layout)44 TEST_F(TeeuiDrawLabelTextTest, Test_12_char_8_group_phys_button_layout) {
45 int error = runRenderTest("en", false /* magnified */, &kText12Character8Group[0]);
46 ASSERT_EQ(error, 0);
47 }
48
TEST_F(TeeuiDrawLabelTextTest,Test_12_char_8_group_phys_button_layout_magnified)49 TEST_F(TeeuiDrawLabelTextTest, Test_12_char_8_group_phys_button_layout_magnified) {
50 int error = runRenderTest("en", true /* magnified */, &kText12Character8Group[0]);
51 ASSERT_EQ(error, 0);
52 }
53
TEST_F(TeeuiDrawLabelTextTest,Test_100_char_1_group_phys_button_layout)54 TEST_F(TeeuiDrawLabelTextTest, Test_100_char_1_group_phys_button_layout) {
55 int error = runRenderTest("en", false /* magnified */, &kText100Character1Group[0]);
56 ASSERT_EQ(error, 0);
57 }
58
TEST_F(TeeuiDrawLabelTextTest,Test_100_char_1_group_phys_button_layout_magnified)59 TEST_F(TeeuiDrawLabelTextTest, Test_100_char_1_group_phys_button_layout_magnified) {
60 int error = runRenderTest("en", true /* magnified */, &kText100Character1Group[0]);
61 ASSERT_EQ(error, 0);
62 }
63
TEST_F(TeeuiDrawLabelTextTest,Test_empty_text_phys_button_layout)64 TEST_F(TeeuiDrawLabelTextTest, Test_empty_text_phys_button_layout) {
65 int error = runRenderTest("en", false /* magnified */, "");
66 ASSERT_EQ(error, 0);
67 }
68
TEST_F(TeeuiDrawLabelTextTest,Test_empty_text_phys_button_layout_magnified)69 TEST_F(TeeuiDrawLabelTextTest, Test_empty_text_phys_button_layout_magnified) {
70 int error = runRenderTest("en", true /* magnified */, "");
71 ASSERT_EQ(error, 0);
72 }
73
TEST_F(TeeuiDrawLabelTextTest,Test_12_char_8_group_touch_button_layout)74 TEST_F(TeeuiDrawLabelTextTest, Test_12_char_8_group_touch_button_layout) {
75 int error = runRenderTest("en", false /* magnified */, &kText12Character8Group[0],
76 example::kTouchButtonLayout);
77 ASSERT_EQ(error, 0);
78 }
79
TEST_F(TeeuiDrawLabelTextTest,Test_12_char_8_group_touch_button_layout_magnified)80 TEST_F(TeeuiDrawLabelTextTest, Test_12_char_8_group_touch_button_layout_magnified) {
81 int error = runRenderTest("en", true /* magnified */, &kText12Character8Group[0],
82 example::kTouchButtonLayout);
83 ASSERT_EQ(error, 0);
84 }
85
TEST_F(TeeuiDrawLabelTextTest,Test_100_char_1_group_touch_button_layout)86 TEST_F(TeeuiDrawLabelTextTest, Test_100_char_1_group_touch_button_layout) {
87 int error = runRenderTest("en", false /* magnified */, &kText100Character1Group[0],
88 example::kTouchButtonLayout);
89 ASSERT_EQ(error, 0);
90 }
91
TEST_F(TeeuiDrawLabelTextTest,Test_100_char_1_group_touch_button_layout_magnified)92 TEST_F(TeeuiDrawLabelTextTest, Test_100_char_1_group_touch_button_layout_magnified) {
93 int error = runRenderTest("en", true /* magnified */, &kText100Character1Group[0],
94 example::kTouchButtonLayout);
95 ASSERT_EQ(error, 0);
96 }
97
TEST_F(TeeuiDrawLabelTextTest,Test_empty_text_touch_button_layout)98 TEST_F(TeeuiDrawLabelTextTest, Test_empty_text_touch_button_layout) {
99 int error = runRenderTest("en", false /* magnified */, "", example::kTouchButtonLayout);
100 ASSERT_EQ(error, 0);
101 }
102
TEST_F(TeeuiDrawLabelTextTest,Test_empty_text_touch_button_layout_magnified)103 TEST_F(TeeuiDrawLabelTextTest, Test_empty_text_touch_button_layout_magnified) {
104 int error = runRenderTest("en", true /* magnified */, "", example::kTouchButtonLayout);
105 ASSERT_EQ(error, 0);
106 }
107
108 } // namespace test
109
110 } // namespace teeui
111