• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 static constexpr const char kTextMultiLine[] =
43     "Line1\n"
44     "Line2. The next line is blank\n"
45     "\n"
46     "Line4.  This line will wrap onto other lines as it is quite long.\n"
47     "LineN\n"
48     "\n";
49 
50 class TeeuiDrawLabelTextTest : public ::testing::Test {};
51 
TEST_F(TeeuiDrawLabelTextTest,Test_12_char_8_group_phys_button_layout)52 TEST_F(TeeuiDrawLabelTextTest, Test_12_char_8_group_phys_button_layout) {
53     int error = runRenderTest("en", false /* magnified */, false, &kText12Character8Group[0]);
54     ASSERT_EQ(error, 0);
55 }
56 
TEST_F(TeeuiDrawLabelTextTest,Test_12_char_8_group_phys_button_layout_magnified)57 TEST_F(TeeuiDrawLabelTextTest, Test_12_char_8_group_phys_button_layout_magnified) {
58     int error = runRenderTest("en", true /* magnified */, false, &kText12Character8Group[0]);
59     ASSERT_EQ(error, 0);
60 }
61 
TEST_F(TeeuiDrawLabelTextTest,Test_100_char_1_group_phys_button_layout)62 TEST_F(TeeuiDrawLabelTextTest, Test_100_char_1_group_phys_button_layout) {
63     int error = runRenderTest("en", false /* magnified */, false, &kText100Character1Group[0]);
64     ASSERT_EQ(error, 0);
65 }
66 
TEST_F(TeeuiDrawLabelTextTest,Test_100_char_1_group_phys_button_layout_magnified)67 TEST_F(TeeuiDrawLabelTextTest, Test_100_char_1_group_phys_button_layout_magnified) {
68     int error = runRenderTest("en", true /* magnified */, false, &kText100Character1Group[0]);
69     ASSERT_EQ(error, 0);
70 }
71 
TEST_F(TeeuiDrawLabelTextTest,Test_multi_line_phys_button_layout)72 TEST_F(TeeuiDrawLabelTextTest, Test_multi_line_phys_button_layout) {
73     int error = runRenderTest("en", false /* magnified */, false, &kTextMultiLine[0]);
74     ASSERT_EQ(error, 0);
75 }
76 
TEST_F(TeeuiDrawLabelTextTest,Test_multi_line_phys_button_layout_magnified)77 TEST_F(TeeuiDrawLabelTextTest, Test_multi_line_phys_button_layout_magnified) {
78     int error = runRenderTest("en", true /* magnified */, false, &kTextMultiLine[0]);
79     ASSERT_EQ(error, 0);
80 }
81 
TEST_F(TeeuiDrawLabelTextTest,Test_empty_text_phys_button_layout)82 TEST_F(TeeuiDrawLabelTextTest, Test_empty_text_phys_button_layout) {
83     int error = runRenderTest("en", false /* magnified */, false, "");
84     ASSERT_EQ(error, 0);
85 }
86 
TEST_F(TeeuiDrawLabelTextTest,Test_empty_text_phys_button_layout_magnified)87 TEST_F(TeeuiDrawLabelTextTest, Test_empty_text_phys_button_layout_magnified) {
88     int error = runRenderTest("en", true /* magnified */, false, "");
89     ASSERT_EQ(error, 0);
90 }
91 
TEST_F(TeeuiDrawLabelTextTest,Test_12_char_8_group_touch_button_layout)92 TEST_F(TeeuiDrawLabelTextTest, Test_12_char_8_group_touch_button_layout) {
93     int error = runRenderTest("en", false /* magnified */, false, &kText12Character8Group[0],
94                               example::kTouchButtonLayout);
95     ASSERT_EQ(error, 0);
96 }
97 
TEST_F(TeeuiDrawLabelTextTest,Test_12_char_8_group_touch_button_layout_magnified)98 TEST_F(TeeuiDrawLabelTextTest, Test_12_char_8_group_touch_button_layout_magnified) {
99     int error = runRenderTest("en", true /* magnified */, false, &kText12Character8Group[0],
100                               example::kTouchButtonLayout);
101     ASSERT_EQ(error, 0);
102 }
103 
TEST_F(TeeuiDrawLabelTextTest,Test_100_char_1_group_touch_button_layout)104 TEST_F(TeeuiDrawLabelTextTest, Test_100_char_1_group_touch_button_layout) {
105     int error = runRenderTest("en", false /* magnified */, false, &kText100Character1Group[0],
106                               example::kTouchButtonLayout);
107     ASSERT_EQ(error, 0);
108 }
109 
TEST_F(TeeuiDrawLabelTextTest,Test_100_char_1_group_touch_button_layout_magnified)110 TEST_F(TeeuiDrawLabelTextTest, Test_100_char_1_group_touch_button_layout_magnified) {
111     int error = runRenderTest("en", true /* magnified */, false, &kText100Character1Group[0],
112                               example::kTouchButtonLayout);
113     ASSERT_EQ(error, 0);
114 }
115 
TEST_F(TeeuiDrawLabelTextTest,Test_empty_text_touch_button_layout)116 TEST_F(TeeuiDrawLabelTextTest, Test_empty_text_touch_button_layout) {
117     int error = runRenderTest("en", false /* magnified */, false, "", example::kTouchButtonLayout);
118     ASSERT_EQ(error, 0);
119 }
120 
TEST_F(TeeuiDrawLabelTextTest,Test_empty_text_touch_button_layout_magnified)121 TEST_F(TeeuiDrawLabelTextTest, Test_empty_text_touch_button_layout_magnified) {
122     int error = runRenderTest("en", true /* magnified */, false, "", example::kTouchButtonLayout);
123     ASSERT_EQ(error, 0);
124 }
125 
126 }  // namespace test
127 
128 }  // namespace teeui
129