1 /*
2 * Copyright 2019 The Android Open Source Project
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 #include <string>
18
19 #include <gtest/gtest.h>
20
21 #include "os/system_properties.h"
22
23 namespace testing {
24
25 using bluetooth::os::ClearSystemPropertiesForHost;
26 using bluetooth::os::GetSystemProperty;
27 using bluetooth::os::SetSystemProperty;
28
TEST(SystemPropertiesTest,set_and_get_test)29 TEST(SystemPropertiesTest, set_and_get_test) {
30 ASSERT_TRUE(SetSystemProperty("persist.bluetooth.factoryreset", "true"));
31 auto ret = GetSystemProperty("persist.bluetooth.factoryreset");
32 ASSERT_TRUE(ret);
33 ASSERT_EQ(ret, "true");
34 ASSERT_TRUE(SetSystemProperty("persist.bluetooth.factoryreset", "false"));
35 ret = GetSystemProperty("persist.bluetooth.factoryreset");
36 ASSERT_TRUE(ret);
37 ASSERT_EQ(ret, "false");
38 ret = GetSystemProperty("persist.bluetooth.factoryreset_do_not_exist");
39 ASSERT_FALSE(ret);
40 ClearSystemPropertiesForHost();
41 ASSERT_FALSE(GetSystemProperty("persist.bluetooth.factoryreset"));
42 }
43
44 } // namespace testing