Home | History | Annotate | Download | only in tests
      1 /*
      2  * Copyright (C) 2017, 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/scanning/offload/scan_stats.h"
     22 #include "wificond/tests/offload_hal_test_constants.h"
     23 
     24 using ::com::android::server::wifi::wificond::NativeScanStats;
     25 using namespace android::wificond::offload_hal_test_constants;
     26 
     27 namespace android {
     28 namespace wificond {
     29 
     30 class ScanStatsTest : public ::testing::Test {};
     31 
     32 TEST_F(ScanStatsTest, ParcelableTest) {
     33   std::vector<uint8_t> histogram_channels;
     34   for (size_t i = 0; i < kNumChannelsInHistogram; i++) {
     35     histogram_channels.push_back(kNumChannelsInHistogram - 1 - i);
     36   }
     37   NativeScanStats scan_stats_in(kDefaultNumScansRequestedByWifi,
     38                                 kDefaultNumScansServicedByWifi,
     39                                 kScanDurationTotalMs, kSubscriptionDurationMs,
     40                                 kNumChannelsTotalScanned, histogram_channels);
     41   Parcel parcel;
     42   EXPECT_EQ(::android::OK, scan_stats_in.writeToParcel(&parcel));
     43   NativeScanStats scan_stats_out;
     44   parcel.setDataPosition(0);
     45   EXPECT_EQ(::android::OK, scan_stats_out.readFromParcel(&parcel));
     46   EXPECT_TRUE(scan_stats_in == scan_stats_out);
     47 }
     48 
     49 }  // namespace wificond
     50 }  // namespace android
     51