1 /*
2 * Copyright (c) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include "country_code_manager_test.h"
17
18 #include "country_code_callback_host.h"
19 #include "country_code_manager.h"
20 #include "location_log.h"
21
22 using namespace testing::ext;
23 namespace OHOS {
24 namespace Location {
SetUp()25 void CountryCodeManagerTest::SetUp()
26 {
27 }
28
TearDown()29 void CountryCodeManagerTest::TearDown()
30 {
31 }
32
33 HWTEST_F(CountryCodeManagerTest, GetIsoCountryCode001, TestSize.Level1)
34 {
35 GTEST_LOG_(INFO)
36 << "CountryCodeManagerTest, GetIsoCountryCode001, TestSize.Level1";
37 LBSLOGI(COUNTRY_CODE, "[CountryCodeManagerTest] GetIsoCountryCode001 begin");
38 std::shared_ptr<CountryCodeManager> countryCodeManager =
39 std::make_shared<CountryCodeManager>();
40 EXPECT_NE(nullptr, countryCodeManager->GetIsoCountryCode());
41 LBSLOGI(COUNTRY_CODE, "[CountryCodeManagerTest] GetIsoCountryCode001 end");
42 }
43
44 HWTEST_F(CountryCodeManagerTest, UnregisterCountryCodeCallback001, TestSize.Level1)
45 {
46 GTEST_LOG_(INFO)
47 << "CountryCodeManagerTest, UnregisterCountryCodeCallback001, TestSize.Level1";
48 LBSLOGI(COUNTRY_CODE, "[CountryCodeManagerTest] UnregisterCountryCodeCallback001 begin");
49 std::shared_ptr<CountryCodeManager> countryCodeManager =
50 std::make_shared<CountryCodeManager>();
51 auto callback = sptr<CountryCodeCallbackHost>(new (std::nothrow) CountryCodeCallbackHost());
52 countryCodeManager->UnregisterCountryCodeCallback(callback);
53 LBSLOGI(COUNTRY_CODE, "[CountryCodeManagerTest] UnregisterCountryCodeCallback001 end");
54 }
55
56 HWTEST_F(CountryCodeManagerTest, UnregisterCountryCodeCallback002, TestSize.Level1)
57 {
58 GTEST_LOG_(INFO)
59 << "CountryCodeManagerTest, UnregisterCountryCodeCallback002, TestSize.Level1";
60 LBSLOGI(COUNTRY_CODE, "[CountryCodeManagerTest] UnregisterCountryCodeCallback002 begin");
61 std::shared_ptr<CountryCodeManager> countryCodeManager =
62 std::make_shared<CountryCodeManager>();
63 countryCodeManager->UnregisterCountryCodeCallback(nullptr);
64 LBSLOGI(COUNTRY_CODE, "[CountryCodeManagerTest] UnregisterCountryCodeCallback002 end");
65 }
66
67 HWTEST_F(CountryCodeManagerTest, RegisterCountryCodeCallback001, TestSize.Level1)
68 {
69 GTEST_LOG_(INFO)
70 << "CountryCodeManagerTest, RegisterCountryCodeCallback001, TestSize.Level1";
71 LBSLOGI(COUNTRY_CODE, "[CountryCodeManagerTest] RegisterCountryCodeCallback001 begin");
72 std::shared_ptr<CountryCodeManager> countryCodeManager =
73 std::make_shared<CountryCodeManager>();
74 auto callback = sptr<CountryCodeCallbackHost>(new (std::nothrow) CountryCodeCallbackHost());
75 countryCodeManager->RegisterCountryCodeCallback(callback, 0);
76 LBSLOGI(COUNTRY_CODE, "[CountryCodeManagerTest] RegisterCountryCodeCallback001 end");
77 }
78
79 HWTEST_F(CountryCodeManagerTest, RegisterCountryCodeCallback002, TestSize.Level1)
80 {
81 GTEST_LOG_(INFO)
82 << "CountryCodeManagerTest, RegisterCountryCodeCallback002, TestSize.Level1";
83 LBSLOGI(COUNTRY_CODE, "[CountryCodeManagerTest] RegisterCountryCodeCallback002 begin");
84 std::shared_ptr<CountryCodeManager> countryCodeManager =
85 std::make_shared<CountryCodeManager>();
86 countryCodeManager->RegisterCountryCodeCallback(nullptr, 0);
87 LBSLOGI(COUNTRY_CODE, "[CountryCodeManagerTest] RegisterCountryCodeCallback002 end");
88 }
89
90 HWTEST_F(CountryCodeManagerTest, ReSubscribeEvent001, TestSize.Level1)
91 {
92 GTEST_LOG_(INFO)
93 << "CountryCodeManagerTest, ReSubscribeEvent001, TestSize.Level1";
94 LBSLOGI(COUNTRY_CODE, "[CountryCodeManagerTest] ReSubscribeEvent001 begin");
95 std::shared_ptr<CountryCodeManager> countryCodeManager =
96 std::make_shared<CountryCodeManager>();
97 countryCodeManager->ReSubscribeEvent();
98 LBSLOGI(COUNTRY_CODE, "[CountryCodeManagerTest] ReSubscribeEvent001 end");
99 }
100
101 HWTEST_F(CountryCodeManagerTest, ReSubscribeEvent002, TestSize.Level1)
102 {
103 GTEST_LOG_(INFO)
104 << "CountryCodeManagerTest, ReSubscribeEvent002, TestSize.Level1";
105 LBSLOGI(COUNTRY_CODE, "[CountryCodeManagerTest] ReSubscribeEvent002 begin");
106 std::shared_ptr<CountryCodeManager> countryCodeManager =
107 std::make_shared<CountryCodeManager>();
108 auto callback = sptr<CountryCodeCallbackHost>(new (std::nothrow) CountryCodeCallbackHost());
109 countryCodeManager->RegisterCountryCodeCallback(callback, 0);
110 countryCodeManager->ReSubscribeEvent();
111 LBSLOGI(COUNTRY_CODE, "[CountryCodeManagerTest] ReSubscribeEvent002 end");
112 }
113
114 HWTEST_F(CountryCodeManagerTest, ReUnsubscribeEvent001, TestSize.Level1)
115 {
116 GTEST_LOG_(INFO)
117 << "CountryCodeManagerTest, ReUnsubscribeEvent001, TestSize.Level1";
118 LBSLOGI(COUNTRY_CODE, "[CountryCodeManagerTest] ReUnsubscribeEvent001 begin");
119 std::shared_ptr<CountryCodeManager> countryCodeManager =
120 std::make_shared<CountryCodeManager>();
121 countryCodeManager->ReUnsubscribeEvent();
122 LBSLOGI(COUNTRY_CODE, "[CountryCodeManagerTest] ReUnsubscribeEvent001 end");
123 }
124
125 HWTEST_F(CountryCodeManagerTest, ReUnsubscribeEvent002, TestSize.Level1)
126 {
127 GTEST_LOG_(INFO)
128 << "CountryCodeManagerTest, ReUnsubscribeEvent002, TestSize.Level1";
129 LBSLOGI(COUNTRY_CODE, "[CountryCodeManagerTest] ReUnsubscribeEvent002 begin");
130 std::shared_ptr<CountryCodeManager> countryCodeManager =
131 std::make_shared<CountryCodeManager>();
132 auto callback = sptr<CountryCodeCallbackHost>(new (std::nothrow) CountryCodeCallbackHost());
133 countryCodeManager->RegisterCountryCodeCallback(callback, 0);
134 countryCodeManager->ReUnsubscribeEvent();
135 LBSLOGI(COUNTRY_CODE, "[CountryCodeManagerTest] ReUnsubscribeEvent002 end");
136 }
137 } // namespace Location
138 } // namespace OHOS