2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 * @file TestCases_GlobalDAO.cpp
18 * @author Pawel Sikorski (p.sikorski@samsung.com)
20 * @brief This file contains tests for global dao class.
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>
33 using namespace WrtDB;
36 const DPL::String widgetPackage5(L"widgetpackage5");
39 RUNNER_TEST_GROUP_INIT(DAO)
42 * Name: global_dao_developer_mode
43 * Description: tests if developer mode is correctly set and get
44 * Expected: received developer shoudl match the one was set
46 RUNNER_TEST(global_dao_developer_mode)
48 bool prev_mode = GlobalDAO::GetDeveloperMode();
49 GlobalDAO::SetDeveloperMode(false);
50 RUNNER_ASSERT_MSG(!GlobalDAO::GetDeveloperMode(), "set false failed");
52 GlobalDAO::SetDeveloperMode(true);
53 RUNNER_ASSERT_MSG(GlobalDAO::GetDeveloperMode(), "set true failed");
54 GlobalDAO::SetDeveloperMode(prev_mode);
58 * Name: home_network_data_usage
59 * Description: tests if HomeNetworkDataUsage is correctly set and get
60 * Expected: received developer shoudl match the one was set
62 RUNNER_TEST(home_network_data_usage)
64 GlobalDAO::NetworkAccessMode original =
65 GlobalDAO::GetHomeNetworkDataUsage();
67 GlobalDAO::SetHomeNetworkDataUsage(GlobalDAO::CONNECT_AUTOMATICALLY);
68 RUNNER_ASSERT_MSG(GlobalDAO::CONNECT_AUTOMATICALLY ==
69 GlobalDAO::GetHomeNetworkDataUsage(), "Value not updated");
71 GlobalDAO::SetHomeNetworkDataUsage(GlobalDAO::ALWAYS_ASK);
72 RUNNER_ASSERT_MSG(GlobalDAO::ALWAYS_ASK ==
73 GlobalDAO::GetHomeNetworkDataUsage(), "Value not updated");
75 GlobalDAO::SetHomeNetworkDataUsage(GlobalDAO::NEVER_CONNECT);
76 RUNNER_ASSERT_MSG(GlobalDAO::NEVER_CONNECT ==
77 GlobalDAO::GetHomeNetworkDataUsage(), "Value not updated");
79 GlobalDAO::SetHomeNetworkDataUsage(original);
80 RUNNER_ASSERT_MSG(original == GlobalDAO::GetHomeNetworkDataUsage(),
85 * Name: roaming_data_usage
86 * Description: tests if RoamingDataUsage is correctly set and get
87 * Expected: received developer shoudl match the one was set
89 RUNNER_TEST(roaming_data_usage)
91 GlobalDAO::NetworkAccessMode original =
92 GlobalDAO::GetRoamingDataUsage();
94 GlobalDAO::SetRoamingDataUsage(GlobalDAO::CONNECT_AUTOMATICALLY);
95 RUNNER_ASSERT_MSG(GlobalDAO::CONNECT_AUTOMATICALLY ==
96 GlobalDAO::GetRoamingDataUsage(), "Value not updated");
98 GlobalDAO::SetRoamingDataUsage(GlobalDAO::ALWAYS_ASK);
99 RUNNER_ASSERT_MSG(GlobalDAO::ALWAYS_ASK ==
100 GlobalDAO::GetRoamingDataUsage(), "Value not updated");
102 GlobalDAO::SetRoamingDataUsage(GlobalDAO::NEVER_CONNECT);
103 RUNNER_ASSERT_MSG(GlobalDAO::NEVER_CONNECT ==
104 GlobalDAO::GetRoamingDataUsage(), "Value not updated");
106 GlobalDAO::SetRoamingDataUsage(original);
107 RUNNER_ASSERT_MSG(original == GlobalDAO::GetRoamingDataUsage(),
108 "Value not updated");