Renaming tests binaries
[framework/web/wrt-commons.git] / tests / files_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 WrtDB::LanguageTagList generateLanguageTags()
34 {
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 =
44     L"/opt/share/widget/tests/localization/widget1/";
45 static const DPL::String widget2Path =
46     L"/opt/share/widget/tests/localization/widget2/";
47 } // anonymous namespace
48
49 RUNNER_TEST(test01_getFilePathInWidgetPackageFromUrl){
50     const int widgetHandle = 1;
51     WrtDB::WidgetDAO dao(widgetHandle);
52     //dao.setPath(widget1Path);
53
54     auto result = W3CFileLocalization::getFilePathInWidgetPackageFromUrl(
55             widgetHandle,
56             languageTags,
57             L"widget://one");
58
59     RUNNER_ASSERT(
60         *result ==
61         L"/opt/share/widget/tests/localization/widget1/locales/pl-en/one");
62 }
63
64 RUNNER_TEST(test02_getFilePathInWidgetPackageFromUrl){
65     const int widgetHandle = 2;
66     WrtDB::WidgetDAO dao(widgetHandle);
67     //dao.setPath(widget2Path);
68
69     auto result = W3CFileLocalization::getFilePathInWidgetPackageFromUrl(
70             widgetHandle,
71             languageTags,
72             L"widget://one");
73
74     RUNNER_ASSERT(
75         *result ==
76         L"/opt/share/widget/tests/localization/widget2/locales/pl-en/one");
77 }
78
79 RUNNER_TEST(test03_getFilePathInWidgetPackageFromUrl){
80     const int widgetHandle = 2;
81     WrtDB::WidgetDAO dao(widgetHandle);
82     //dao.setPath(widget2Path);
83
84     auto result = W3CFileLocalization::getFilePathInWidgetPackageFromUrl(
85             widgetHandle,
86             languageTags,
87             L"widget://two");
88
89     RUNNER_ASSERT(
90         *result ==
91         L"/opt/share/widget/tests/localization/widget2/locales/en-en/two");
92 }
93
94 RUNNER_TEST(test04_getFilePathInWidgetPackage){
95     const int widgetHandle = 1;
96     WrtDB::WidgetDAO dao(widgetHandle);
97     //dao.setPath(widget1Path);
98
99     auto result = W3CFileLocalization::getFilePathInWidgetPackage(
100             widgetHandle,
101             languageTags,
102             L"one");
103
104     RUNNER_ASSERT(*result == L"locales/pl-en/one");
105 }
106
107 RUNNER_TEST(test05_getFilePathInWidgetPackage){
108     const int widgetHandle = 2;
109     WrtDB::WidgetDAO dao(widgetHandle);
110     //dao.setPath(widget2Path);
111
112     auto result = W3CFileLocalization::getFilePathInWidgetPackage(
113             widgetHandle,
114             languageTags,
115             L"two");
116
117     RUNNER_ASSERT(*result == L"locales/en-en/two");
118 }
119