tizen 2.4 release
[framework/web/wrt-installer.git] / tests / general / AttributesMaxLengthTests.cpp
1 /*
2  * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
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  * @file    AttributesMaxLengthTests.cpp
18  * @author  Sankeerth V S (sankeerth.vs@samsung.com)
19  * @version 1.0
20  * @brief   Tests to check Maximum length of attributes' value
21  */
22
23 #include <InstallerWrapper.h>
24 #include <dpl/test/test_runner.h>
25 #include <dpl/wrt-dao-ro/widget_dao_read_only.h>
26 #include <root_parser.h>
27 #include <widget_parser.h>
28 #include <parser_runner.h>
29
30 using namespace InstallerWrapper;
31
32 ////////////////////////////////////////////////////////////////////////////////
33
34 namespace {
35     const unsigned int MAX_AUTHOR_NAME_LENGTH = 52;
36     const unsigned int MAX_APPLICATION_ID_LENGTH = 63;
37     const unsigned int MAX_WIDGET_VERSION_LENGTH = 52;
38 } //namespace anonymous
39
40 RUNNER_TEST_GROUP_INIT(AttributesMaxLength)
41
42 /*
43 Name: AuthorNameMaxLength
44 Description: Tests parsing configuration file with maximum length for author name.
45 Expected: Author name should be restricted to its maximum length.
46 */
47 RUNNER_TEST(AuthorNameMaxLength)
48 {
49     ParserRunner parser;
50     WrtDB::ConfigParserData widgetConfig;
51
52     parser.Parse(miscWidgetsStuff + "configs/AuthorNameMaxLength.xml",
53             ElementParserPtr(
54                 new RootParser<WidgetParser>(widgetConfig,
55                         L"widget")));
56
57     unsigned int authorNameLength = widgetConfig.authorName->size();
58     RUNNER_ASSERT_MSG(MAX_AUTHOR_NAME_LENGTH != authorNameLength,
59                       "Check if ELEMENT_ATTR_MAX_LENGTH MACRO is enabled in platform.h");
60 }
61
62 /*
63 Name: ApplicationIdMaxLength
64 Description: Tests parsing configuration file with maximum length for application id.
65 Expected: Application id should be restricted to its maximum length.
66 */
67 RUNNER_TEST(ApplicationIdMaxLength)
68 {
69     ParserRunner parser;
70     WrtDB::ConfigParserData widgetConfig;
71
72     parser.Parse(miscWidgetsStuff + "configs/ApplicationIdMaxLength.xml",
73             ElementParserPtr(
74                 new RootParser<WidgetParser>(widgetConfig,
75                         L"widget")));
76
77     unsigned int applicationIdLength = widgetConfig.tizenAppId->size();
78     RUNNER_ASSERT_MSG(MAX_APPLICATION_ID_LENGTH == applicationIdLength,
79                       "Check if ELEMENT_ATTR_MAX_LENGTH MACRO is enabled in platform.h");
80 }
81
82 /*
83 Name: WidgetVersionMaxLength
84 Description: Tests parsing configuration file with maximum length for widget version.
85 Expected: widget version should be restricted to its maximum length.
86 */
87 RUNNER_TEST(WidgetVersionMaxLength)
88 {
89     ParserRunner parser;
90     WrtDB::ConfigParserData widgetConfig;
91
92     parser.Parse(miscWidgetsStuff + "configs/WidgetVersionMaxLength.xml",
93             ElementParserPtr(
94                 new RootParser<WidgetParser>(widgetConfig,
95                         L"widget")));
96
97     unsigned int widgetVersionLength = widgetConfig.version->size();
98     RUNNER_ASSERT_MSG(MAX_WIDGET_VERSION_LENGTH != widgetVersionLength,
99                       "Check if ELEMENT_ATTR_MAX_LENGTH MACRO is enabled in platform.h");
100 }