summaryrefslogtreecommitdiffstats
path: root/chromium/base/android/android_image_reader_compat_unittest.cc
blob: af31ec02faeffe16eef9874f31c1d4ac7f485a3a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "base/android/android_image_reader_compat.h"

#include <stdint.h>
#include <memory>

#include "base/android/build_info.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace base {
namespace android {

class AndroidImageReaderTest : public testing::Test {
 public:
  AndroidImageReaderTest() = default;
  ~AndroidImageReaderTest() override = default;
};

// Getting instance of AndroidImageReader will invoke AndroidImageReader
// constructor which will dlopen the mediandk and androidndk .so files and do
// all the required symbol lookups.
TEST_F(AndroidImageReaderTest, GetImageReaderInstance) {
  // It is expected that image reader support will be available from android
  // version OREO.
  EXPECT_EQ(AndroidImageReader::GetInstance().IsSupported(),
            base::android::BuildInfo::GetInstance()->sdk_int() >=
                base::android::SDK_VERSION_P);
}

// There should be only 1 instance of AndroidImageReader im memory. Hence 2
// instances should have same memory address.
TEST_F(AndroidImageReaderTest, CompareImageReaderInstance) {
  AndroidImageReader& a1 = AndroidImageReader::GetInstance();
  AndroidImageReader& a2 = AndroidImageReader::GetInstance();
  ASSERT_EQ(&a1, &a2);
}

}  // namespace android
}  // namespace base