android_image_reader_compat_unittest.cc 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // Copyright 2018 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "base/android/android_image_reader_compat.h"
  5. #include <stdint.h>
  6. #include <memory>
  7. #include "base/android/build_info.h"
  8. #include "testing/gtest/include/gtest/gtest.h"
  9. namespace base {
  10. namespace android {
  11. class AndroidImageReaderTest : public testing::Test {
  12. public:
  13. AndroidImageReaderTest() = default;
  14. ~AndroidImageReaderTest() override = default;
  15. };
  16. // Getting instance of AndroidImageReader will invoke AndroidImageReader
  17. // constructor which will dlopen the mediandk and androidndk .so files and do
  18. // all the required symbol lookups.
  19. TEST_F(AndroidImageReaderTest, GetImageReaderInstance) {
  20. // It is expected that image reader support will be available from android
  21. // version OREO.
  22. EXPECT_EQ(AndroidImageReader::GetInstance().IsSupported(),
  23. base::android::BuildInfo::GetInstance()->sdk_int() >=
  24. base::android::SDK_VERSION_P);
  25. }
  26. // There should be only 1 instance of AndroidImageReader im memory. Hence 2
  27. // instances should have same memory address.
  28. TEST_F(AndroidImageReaderTest, CompareImageReaderInstance) {
  29. AndroidImageReader& a1 = AndroidImageReader::GetInstance();
  30. AndroidImageReader& a2 = AndroidImageReader::GetInstance();
  31. ASSERT_EQ(&a1, &a2);
  32. }
  33. } // namespace android
  34. } // namespace base