b752bf50299c4996ba79de08501aa7739bb3a583
[platform/framework/web/wrt-commons.git] / tests / dpl / localization / test_suite01.cpp
1 /*
2  * Copyright (c) 2011 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  * This file contains the declaration of widget dao class.
18  *
19  * @file    test_suite01.cpp
20  * @author  Krzysztof Jackiewicz (k.jackiewicz@samsung.com)
21  * @version 1.0
22  * @brief
23  */
24
25 #include <dpl/log/log.h>
26 #include <dpl/test/test_runner.h>
27
28 //#include "mockup_include/dpl/wrt-dao-rw/widget_dao.h"
29 #include <dpl/wrt-dao-rw/widget_dao.h>
30 #include <dpl/localization/w3c_file_localization.h>
31
32 namespace {
33
34 WrtDB::LanguageTagList generateLanguageTags(){
35     WrtDB::LanguageTagList tags;
36     tags.push_back(L"pl-pl");
37     tags.push_back(L"en-en");
38     tags.push_back(L"pl-en");
39     return tags;
40 }
41
42 static const WrtDB::LanguageTagList languageTags = generateLanguageTags();
43 static const DPL::String widget1Path = L"/opt/share/widget/tests/localization/widget1/";
44 static const DPL::String widget2Path = L"/opt/share/widget/tests/localization/widget2/";
45
46 } // anonymous namespace
47
48 RUNNER_TEST(test01_getFilePathInWidgetPackageFromUrl){
49     const int widgetHandle = 1;
50     WrtDB::WidgetDAO dao(widgetHandle);
51     //dao.setPath(widget1Path);
52
53     auto result = W3CFileLocalization::getFilePathInWidgetPackageFromUrl(
54         widgetHandle,
55         languageTags,
56         L"widget://one");
57
58     RUNNER_ASSERT(*result == L"/opt/share/widget/tests/localization/widget1/locales/pl-en/one");
59 }
60
61 RUNNER_TEST(test02_getFilePathInWidgetPackageFromUrl){
62     const int widgetHandle = 2;
63     WrtDB::WidgetDAO dao(widgetHandle);
64     //dao.setPath(widget2Path);
65
66     auto result = W3CFileLocalization::getFilePathInWidgetPackageFromUrl(
67         widgetHandle,
68         languageTags,
69         L"widget://one");
70
71     RUNNER_ASSERT(*result == L"/opt/share/widget/tests/localization/widget2/locales/pl-en/one");
72 }
73
74 RUNNER_TEST(test03_getFilePathInWidgetPackageFromUrl){
75     const int widgetHandle = 2;
76     WrtDB::WidgetDAO dao(widgetHandle);
77     //dao.setPath(widget2Path);
78
79     auto result = W3CFileLocalization::getFilePathInWidgetPackageFromUrl(
80         widgetHandle,
81         languageTags,
82         L"widget://two");
83
84     RUNNER_ASSERT(*result == L"/opt/share/widget/tests/localization/widget2/locales/en-en/two");
85 }
86
87 RUNNER_TEST(test04_getFilePathInWidgetPackage){
88     const int widgetHandle = 1;
89     WrtDB::WidgetDAO dao(widgetHandle);
90     //dao.setPath(widget1Path);
91
92     auto result = W3CFileLocalization::getFilePathInWidgetPackage(
93         widgetHandle,
94         languageTags,
95         L"one");
96
97     RUNNER_ASSERT(*result == L"locales/pl-en/one");
98 }
99
100 RUNNER_TEST(test05_getFilePathInWidgetPackage){
101     const int widgetHandle = 2;
102     WrtDB::WidgetDAO dao(widgetHandle);
103     //dao.setPath(widget2Path);
104
105     auto result = W3CFileLocalization::getFilePathInWidgetPackage(
106         widgetHandle,
107         languageTags,
108         L"two");
109
110     RUNNER_ASSERT(*result == L"locales/en-en/two");
111 }
112