1 /*
2  * Copyright (C) 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 <vector>
18 
19 #include <gtest/gtest.h>
20 
21 #include "wificond/client/native_wifi_client.h"
22 
23 using ::android::net::wifi::nl80211::NativeWifiClient;
24 using std::vector;
25 
26 namespace android {
27 namespace wificond {
28 
29 namespace {
30 
31 const vector<uint8_t> kMacAddress = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 };
32 const vector<uint8_t> kMacAddressOther = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x0F };
33 
34 }  // namespace
35 
36 class NativeWifiClientTest : public ::testing::Test {
37 };
38 
TEST_F(NativeWifiClientTest,NativeWifiClientParcelableTest)39 TEST_F(NativeWifiClientTest, NativeWifiClientParcelableTest) {
40   NativeWifiClient wifi_client;
41   wifi_client.mac_address_ = kMacAddress;
42 
43   Parcel parcel;
44   EXPECT_EQ(::android::OK, wifi_client.writeToParcel(&parcel));
45 
46   NativeWifiClient wifi_client_copy;
47   parcel.setDataPosition(0);
48   EXPECT_EQ(::android::OK, wifi_client_copy.readFromParcel(&parcel));
49 
50   EXPECT_EQ(wifi_client, wifi_client_copy);
51 
52   NativeWifiClient wifi_client_other;
53   wifi_client_other.mac_address_ = kMacAddressOther;
54   EXPECT_FALSE(wifi_client == wifi_client_other);
55 }
56 
57 }  // namespace wificond
58 }  // namespace android
59