1 /*
2 * Copyright (c) 2023 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 #ifdef FEATURE_GEOCODE_SUPPORT
17 #include "geo_convert_callback_host_test.h"
18
19 #include <sys/time.h>
20 #include "common_utils.h"
21 #include "location_log.h"
22 #include "i_geocode_callback.h"
23
24 #include "mock_geo_convert_callback_host.h"
25 #include <gtest/gtest.h>
26 #include "geo_convert_proxy.h"
27
28 using namespace testing;
29 using namespace testing::ext;
30
31 namespace OHOS {
32 namespace Location {
SetUp()33 void GeoConvertCallbackHostTest::SetUp()
34 {
35 }
36
TearDown()37 void GeoConvertCallbackHostTest::TearDown()
38 {
39 }
40
41 HWTEST_F(GeoConvertCallbackHostTest, GeoConvertCallbackHostTest001, TestSize.Level1)
42 {
43 GTEST_LOG_(INFO)
44 << "GeoConvertCallbackHostTest, GeoConvertCallbackHostTest001, TestSize.Level1";
45 LBSLOGI(GEO_CONVERT, "[GeoConvertCallbackHostTest] GeoConvertCallbackHostTest001 begin");
46 auto geoConvertCallvackHost = sptr<MockGeoConvertCallbackHost>(new (std::nothrow) MockGeoConvertCallbackHost());
47 uint32_t code = 3;
48 MessageParcel parcel;
49 parcel.WriteInterfaceToken(GeoConvertProxy::GetDescriptor());
50 MessageParcel reply;
51 MessageOption option;
52 geoConvertCallvackHost->OnRemoteRequest(GeoConvertCallbackHost::RECEIVE_GEOCODE_INFO_EVENT, parcel, reply, option);
53 geoConvertCallvackHost->OnRemoteRequest(GeoConvertCallbackHost::ERROR_INFO_EVENT, parcel, reply, option);
54 geoConvertCallvackHost->OnRemoteRequest(code, parcel, reply, option);
55 LBSLOGI(GEO_CONVERT, "[GeoConvertCallbackHostTest] GeoConvertCallbackHostTest001 end");
56 }
57
58 HWTEST_F(GeoConvertCallbackHostTest, GeoConvertCallbackHostTest002, TestSize.Level1)
59 {
60 GTEST_LOG_(INFO)
61 << "GeoConvertCallbackHostTest, GeoConvertCallbackHostTest002, TestSize.Level1";
62 LBSLOGI(GEO_CONVERT, "[GeoConvertCallbackHostTest] GeoConvertCallbackHostTest002 begin");
63 auto geoConvertCallvackHost = sptr<MockGeoConvertCallbackHost>(new (std::nothrow) MockGeoConvertCallbackHost());
64 uint32_t code = 3;
65 MessageParcel parcel;
66 parcel.WriteInterfaceToken(GeoConvertProxy::GetDescriptor());
67 MessageParcel reply;
68 MessageOption option;
69 geoConvertCallvackHost->OnRemoteRequest(GeoConvertCallbackHost::RECEIVE_GEOCODE_INFO_EVENT, parcel, reply, option);
70 geoConvertCallvackHost->OnRemoteRequest(GeoConvertCallbackHost::ERROR_INFO_EVENT, parcel, reply, option);
71 geoConvertCallvackHost->OnRemoteRequest(code, parcel, reply, option);
72 LBSLOGI(GEO_CONVERT, "[GeoConvertCallbackHostTest] GeoConvertCallbackHostTest002 end");
73 }
74
75 HWTEST_F(GeoConvertCallbackHostTest, GeoConvertCallbackHostTest003, TestSize.Level1)
76 {
77 GTEST_LOG_(INFO)
78 << "GeoConvertCallbackHostTest, GeoConvertCallbackHostTest003, TestSize.Level1";
79 LBSLOGI(GEO_CONVERT, "[GeoConvertCallbackHostTest] GeoConvertCallbackHostTest003 begin");
80 auto geoConvertCallvackHost = sptr<GeoConvertCallbackHost>(new (std::nothrow) GeoConvertCallbackHost());
81 uint32_t code = 3;
82 MessageParcel parcel;
83 parcel.WriteInterfaceToken(GeoConvertProxy::GetDescriptor());
84 MessageParcel reply;
85 MessageOption option;
86 geoConvertCallvackHost->OnRemoteRequest
87 (GeoConvertCallbackHost::RECEIVE_GEOCODE_INFO_EVENT, parcel, reply, option);
88 geoConvertCallvackHost->OnRemoteRequest
89 (GeoConvertCallbackHost::ERROR_INFO_EVENT, parcel, reply, option);
90 geoConvertCallvackHost->OnRemoteRequest(code, parcel, reply, option);
91 LBSLOGI(GEO_CONVERT, "[GeoConvertCallbackHostTest] GeoConvertCallbackHostTest003 end");
92 }
93
94 HWTEST_F(GeoConvertCallbackHostTest, GeoConvertCallbackHostTest004, TestSize.Level1)
95 {
96 GTEST_LOG_(INFO)
97 << "GeoConvertCallbackHostTest, GeoConvertCallbackHostTest004, TestSize.Level1";
98 LBSLOGI(GEO_CONVERT, "[GeoConvertCallbackHostTest] GeoConvertCallbackHostTest004 begin");
99 auto geoConvertCallvackHost = sptr<GeoConvertCallbackHost>(new (std::nothrow) GeoConvertCallbackHost());
100 geoConvertCallvackHost->GetResult();
101 LBSLOGI(GEO_CONVERT, "[GeoConvertCallbackHostTest] GeoConvertCallbackHostTest004 end");
102 }
103
104 HWTEST_F(GeoConvertCallbackHostTest, GeoConvertCallbackHostTest005, TestSize.Level1)
105 {
106 GTEST_LOG_(INFO)
107 << "GeoConvertCallbackHostTest, GeoConvertCallbackHostTest005, TestSize.Level1";
108 LBSLOGI(GEO_CONVERT, "[GeoConvertCallbackHostTest] GeoConvertCallbackHostTest005 begin");
109 auto geoConvertCallvackHost = sptr<GeoConvertCallbackHost>(new (std::nothrow) GeoConvertCallbackHost());
110 std::list<std::shared_ptr<GeoAddress>> results;
111 geoConvertCallvackHost->OnResults(results);
112 LBSLOGI(GEO_CONVERT, "[GeoConvertCallbackHostTest] GeoConvertCallbackHostTest005 end");
113 }
114
115 HWTEST_F(GeoConvertCallbackHostTest, GeoConvertCallbackHostTest006, TestSize.Level1)
116 {
117 GTEST_LOG_(INFO)
118 << "GeoConvertCallbackHostTest, GeoConvertCallbackHostTest006, TestSize.Level1";
119 LBSLOGI(GEO_CONVERT, "[GeoConvertCallbackHostTest] GeoConvertCallbackHostTest006 begin");
120 auto geoConvertCallvackHost = sptr<GeoConvertCallbackHost>(new (std::nothrow) GeoConvertCallbackHost());
121 int errorCode = 1;
122 geoConvertCallvackHost->OnErrorReport(errorCode);
123 LBSLOGI(GEO_CONVERT, "[GeoConvertCallbackHostTest] GeoConvertCallbackHostTest006 end");
124 }
125 } // namespace Location
126 } // namespace OHOS
127 #endif // FEATURE_GEOCODE_SUPPORT