OSDN Git Service

c82281f3a24d29dbff2f8657ea3ca83f23f0d170
[android-x86/system-connectivity-wificond.git] / tests / scan_settings_unittest.cpp
1 /*
2  * Copyright (C) 2016, 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 <gtest/gtest.h>
18
19 #include "wificond/scanning/channel_settings.h"
20 #include "wificond/scanning/hidden_network.h"
21
22 using ::com::android::server::wifi::wificond::ChannelSettings;
23 using ::com::android::server::wifi::wificond::HiddenNetwork;
24
25 namespace android {
26 namespace wificond {
27
28 namespace {
29
30 const uint8_t kFakeSsid[] =
31     {'G', 'o', 'o', 'g', 'l', 'e', 'G', 'u', 'e', 's', 't'};
32
33 constexpr uint32_t kFakeFrequency = 5260;
34
35 }  // namespace
36
37 class ScanSettingsTest : public ::testing::Test {
38 };
39
40 TEST_F(ScanSettingsTest, ChannelSettingsParcelableTest) {
41   ChannelSettings channel_settings;
42   channel_settings.frequency_ = kFakeFrequency;
43
44   Parcel parcel;
45   EXPECT_EQ(::android::OK, channel_settings.writeToParcel(&parcel));
46
47   ChannelSettings channel_settings_copy;
48   parcel.setDataPosition(0);
49   EXPECT_EQ(::android::OK, channel_settings_copy.readFromParcel(&parcel));
50
51   EXPECT_EQ(channel_settings, channel_settings_copy);
52 }
53
54 TEST_F(ScanSettingsTest, HiddenNetworkParcelableTest) {
55   HiddenNetwork hidden_network;
56   hidden_network.ssid_ =
57       std::vector<uint8_t>(kFakeSsid, kFakeSsid + sizeof(kFakeSsid));
58
59   Parcel parcel;
60   EXPECT_EQ(::android::OK, hidden_network.writeToParcel(&parcel));
61
62   HiddenNetwork hidden_network_copy;
63   parcel.setDataPosition(0);
64   EXPECT_EQ(::android::OK, hidden_network_copy.readFromParcel(&parcel));
65
66   EXPECT_EQ(hidden_network, hidden_network_copy);
67 }
68
69
70 }  // namespace wificond
71 }  // namespace android