0098eeeb358d992672d39662795aa2c0550cbe40
[framework/web/wrt-commons.git] / tests / dao / TestCases_GlobalDAO.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   * @file   TestCases_GlobalDAO.cpp
18  * @author  Pawel Sikorski (p.sikorski@samsung.com)
19  * @version 1.0
20  * @brief   This file contains tests for global dao class.
21  */
22
23 #include <list>
24 #include <vector>
25 #include <set>
26 #include <dpl/test/test_runner.h>
27 #include <dpl/foreach.h>
28 #include <dpl/exception.h>
29 #include <dpl/string.h>
30 #include <dpl/wrt-dao-rw/global_dao.h>
31 #include <dpl/wrt-dao-ro/wrt_db_types.h>
32
33 using namespace WrtDB;
34
35
36 namespace
37 {
38 const DPL::String widgetPackage5(L"widgetpackage5");
39 } // namespace
40
41 RUNNER_TEST_GROUP_INIT(DAO)
42
43 /*
44 Name: global_dao_developer_mode
45 Description: tests if developer mode is correctly set and get
46 Expected: received developer shoudl match the one was set
47 */
48 RUNNER_TEST(global_dao_developer_mode)
49 {
50     bool prev_mode = GlobalDAO::GetDeveloperMode();
51     GlobalDAO::SetDeveloperMode(false);
52     RUNNER_ASSERT_MSG(!GlobalDAO::GetDeveloperMode(), "set false failed");
53
54     GlobalDAO::SetDeveloperMode(true);
55     RUNNER_ASSERT_MSG(GlobalDAO::GetDeveloperMode(), "set true failed");
56     GlobalDAO::SetDeveloperMode(prev_mode);
57 }
58
59 /*
60 Name: home_network_data_usage
61 Description: tests if HomeNetworkDataUsage is correctly set and get
62 Expected: received developer shoudl match the one was set
63 */
64 RUNNER_TEST(home_network_data_usage)
65 {
66     GlobalDAO::NetworkAccessMode original =
67             GlobalDAO::GetHomeNetworkDataUsage();
68
69     GlobalDAO::SetHomeNetworkDataUsage(GlobalDAO::CONNECT_AUTOMATICALLY);
70     RUNNER_ASSERT_MSG(GlobalDAO::CONNECT_AUTOMATICALLY ==
71             GlobalDAO::GetHomeNetworkDataUsage(), "Value not updated");
72
73     GlobalDAO::SetHomeNetworkDataUsage(GlobalDAO::ALWAYS_ASK);
74     RUNNER_ASSERT_MSG(GlobalDAO::ALWAYS_ASK ==
75             GlobalDAO::GetHomeNetworkDataUsage(), "Value not updated");
76
77     GlobalDAO::SetHomeNetworkDataUsage(GlobalDAO::NEVER_CONNECT);
78     RUNNER_ASSERT_MSG(GlobalDAO::NEVER_CONNECT ==
79             GlobalDAO::GetHomeNetworkDataUsage(), "Value not updated");
80
81     GlobalDAO::SetHomeNetworkDataUsage(original);
82     RUNNER_ASSERT_MSG(original == GlobalDAO::GetHomeNetworkDataUsage(),
83             "Value not updated");
84 }
85
86 /*
87 Name: roaming_data_usage
88 Description: tests if RoamingDataUsage is correctly set and get
89 Expected: received developer shoudl match the one was set
90 */
91 RUNNER_TEST(roaming_data_usage)
92 {
93     GlobalDAO::NetworkAccessMode original =
94             GlobalDAO::GetRoamingDataUsage();
95
96     GlobalDAO::SetRoamingDataUsage(GlobalDAO::CONNECT_AUTOMATICALLY);
97     RUNNER_ASSERT_MSG(GlobalDAO::CONNECT_AUTOMATICALLY ==
98             GlobalDAO::GetRoamingDataUsage(), "Value not updated");
99
100     GlobalDAO::SetRoamingDataUsage(GlobalDAO::ALWAYS_ASK);
101     RUNNER_ASSERT_MSG(GlobalDAO::ALWAYS_ASK ==
102             GlobalDAO::GetRoamingDataUsage(), "Value not updated");
103
104     GlobalDAO::SetRoamingDataUsage(GlobalDAO::NEVER_CONNECT);
105     RUNNER_ASSERT_MSG(GlobalDAO::NEVER_CONNECT ==
106             GlobalDAO::GetRoamingDataUsage(), "Value not updated");
107
108     GlobalDAO::SetRoamingDataUsage(original);
109     RUNNER_ASSERT_MSG(original == GlobalDAO::GetRoamingDataUsage(),
110             "Value not updated");
111 }