2 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.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
8 // http://floralicense.org/license/
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.
21 #include <dali/dali.h>
22 #include <internal/command-line-options.h>
23 #include <dali-test-suite-utils.h>
26 using namespace Dali::Internal::Adaptor;
29 // Called only once before first test is run.
30 void command_line_options_startup(void)
32 test_return_value = TET_UNDEF;
33 optind = 1; // Reset opt for test
36 // Called only once after last test is run
37 void command_line_options_cleanup(void)
39 test_return_value = TET_PASS;
44 int gOriginalOptIndValue(0);
48 int UtcDaliCommandLineOptionsNoArgs(void)
53 const char* argList[1] = { "program" };
54 char** argv = const_cast<char**>(argList);
56 CommandLineOptions options( &argc, &argv );
58 DALI_TEST_EQUALS( argc, 1, TEST_LOCATION );
61 DALI_TEST_EQUALS( options.noVSyncOnRender, 0, TEST_LOCATION );
62 DALI_TEST_EQUALS( options.stageWidth, 0, TEST_LOCATION );
63 DALI_TEST_EQUALS( options.stageHeight, 0, TEST_LOCATION );
64 DALI_TEST_EQUALS( options.stageDPI, "", TEST_LOCATION );
69 int UtcDaliCommandLineOptionsDaliShortArgs(void)
73 const char* argList[] =
80 int argc( sizeof( argList ) / sizeof( argList[0] ) );
81 char** argv = const_cast<char**>(argList);
83 CommandLineOptions options( &argc, &argv );
85 // Should strip out the height and width
86 DALI_TEST_EQUALS( argc, 1, TEST_LOCATION );
89 DALI_TEST_EQUALS( options.noVSyncOnRender, 0, TEST_LOCATION );
90 DALI_TEST_EQUALS( options.stageWidth, 800, TEST_LOCATION );
91 DALI_TEST_EQUALS( options.stageHeight, 1000, TEST_LOCATION );
92 DALI_TEST_EQUALS( options.stageDPI, "4x5", TEST_LOCATION );
97 int UtcDaliCommandLineOptionsDaliLongArgsEqualsSign(void)
101 const char* argList[] =
110 int argc( sizeof( argList ) / sizeof( argList[0] ) );
111 char** argv = const_cast<char**>(argList);
113 CommandLineOptions options( &argc, &argv );
115 // Should strip out the height and width
116 DALI_TEST_EQUALS( argc, 1, TEST_LOCATION );
119 DALI_TEST_EQUALS( options.noVSyncOnRender, 1, TEST_LOCATION );
120 DALI_TEST_EQUALS( options.stageWidth, 800, TEST_LOCATION );
121 DALI_TEST_EQUALS( options.stageHeight, 1000, TEST_LOCATION );
122 DALI_TEST_EQUALS( options.stageDPI, "3x4", TEST_LOCATION );
127 int UtcDaliCommandLineOptionsDaliLongArgsSpaces(void)
131 const char* argList[] =
140 int argc( sizeof( argList ) / sizeof( argList[0] ) );
141 char** argv = const_cast<char**>(argList);
143 CommandLineOptions options( &argc, &argv );
145 // Should strip out the height and width
146 DALI_TEST_EQUALS( argc, 1, TEST_LOCATION );
149 DALI_TEST_EQUALS( options.noVSyncOnRender, 1, TEST_LOCATION );
150 DALI_TEST_EQUALS( options.stageWidth, 800, TEST_LOCATION );
151 DALI_TEST_EQUALS( options.stageHeight, 1000, TEST_LOCATION );
152 DALI_TEST_EQUALS( options.stageDPI, "3x4", TEST_LOCATION );
157 int UtcDaliCommandLineOptionsNonDaliArgs(void)
161 const char* argList[] =
167 int argc( sizeof( argList ) / sizeof( argList[0] ) );
168 char** argv = const_cast<char**>(argList);
170 CommandLineOptions options( &argc, &argv );
172 // Should still be the same
173 DALI_TEST_EQUALS( argc, 4, TEST_LOCATION );
175 // Ensure order has not changed
176 DALI_TEST_EQUALS( argList[0], "program", TEST_LOCATION );
177 DALI_TEST_EQUALS( argList[1], "hello-world", TEST_LOCATION );
178 DALI_TEST_EQUALS( argList[2], "-y", TEST_LOCATION );
179 DALI_TEST_EQUALS( argList[3], "600", TEST_LOCATION );
184 int UtcDaliCommandLineOptionsMixture(void)
186 optind = 1; // Reset opt for test
197 int argc( sizeof( argList ) / sizeof( argList[0] ) );
198 char** argv = argList;
200 CommandLineOptions options( &argc, &argv );
202 // Should still be the same
203 DALI_TEST_EQUALS( argc, 5, TEST_LOCATION );
205 // Ensure order of program name and unhandled options has not changed
206 DALI_TEST_EQUALS( argList[0], "program", TEST_LOCATION );
207 DALI_TEST_EQUALS( argList[1], "hello-world", TEST_LOCATION );
208 DALI_TEST_EQUALS( argList[2], "-y", TEST_LOCATION );
209 DALI_TEST_EQUALS( argList[3], "600", TEST_LOCATION );
210 DALI_TEST_EQUALS( argList[4], "-r", TEST_LOCATION );
215 int UtcDaliCommandLineOptionsMixtureDaliOpsAtStart(void)
228 int argc( sizeof( argList ) / sizeof( argList[0] ) );
229 char** argv = argList;
231 CommandLineOptions options( &argc, &argv );
233 // Should still be the same
234 DALI_TEST_EQUALS( argc, 5, TEST_LOCATION );
236 // Ensure order of program name and unhandled options has not changed
237 DALI_TEST_EQUALS( argList[0], "program", TEST_LOCATION );
238 DALI_TEST_EQUALS( argList[1], "-r", TEST_LOCATION );
239 DALI_TEST_EQUALS( argList[2], "hello-world", TEST_LOCATION );
240 DALI_TEST_EQUALS( argList[3], "-y", TEST_LOCATION );
241 DALI_TEST_EQUALS( argList[4], "600", TEST_LOCATION );
246 int UtcDaliCommandLineOptionsMixtureDaliOpsAtEnd(void)
259 int argc( sizeof( argList ) / sizeof( argList[0] ) );
260 char** argv = argList;
262 CommandLineOptions options( &argc, &argv );
264 // Should still be the same
265 DALI_TEST_EQUALS( argc, 5, TEST_LOCATION );
267 // Ensure order of program name and unhandled options has not changed
268 DALI_TEST_EQUALS( argList[0], "program", TEST_LOCATION );
269 DALI_TEST_EQUALS( argList[1], "hello-world", TEST_LOCATION );
270 DALI_TEST_EQUALS( argList[2], "-y", TEST_LOCATION );
271 DALI_TEST_EQUALS( argList[3], "600", TEST_LOCATION );
272 DALI_TEST_EQUALS( argList[4], "-r", TEST_LOCATION );