scan_stats_unittest.cpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. #include <vector>
  17. #include <gtest/gtest.h>
  18. #include "wificond/scanning/offload/scan_stats.h"
  19. #include "wificond/tests/offload_hal_test_constants.h"
  20. using ::com::android::server::wifi::wificond::NativeScanStats;
  21. using namespace android::wificond::offload_hal_test_constants;
  22. namespace android {
  23. namespace wificond {
  24. class ScanStatsTest : public ::testing::Test {};
  25. TEST_F(ScanStatsTest, ParcelableTest) {
  26. std::vector<uint8_t> histogram_channels;
  27. for (size_t i = 0; i < kNumChannelsInHistogram; i++) {
  28. histogram_channels.push_back(kNumChannelsInHistogram - 1 - i);
  29. }
  30. NativeScanStats scan_stats_in(kDefaultNumScansRequestedByWifi,
  31. kDefaultNumScansServicedByWifi,
  32. kScanDurationTotalMs, kSubscriptionDurationMs,
  33. kNumChannelsTotalScanned, histogram_channels);
  34. Parcel parcel;
  35. EXPECT_EQ(::android::OK, scan_stats_in.writeToParcel(&parcel));
  36. NativeScanStats scan_stats_out;
  37. parcel.setDataPosition(0);
  38. EXPECT_EQ(::android::OK, scan_stats_out.readFromParcel(&parcel));
  39. EXPECT_TRUE(scan_stats_in == scan_stats_out);
  40. }
  41. } // namespace wificond
  42. } // namespace android