summaryrefslogtreecommitdiffstats
path: root/tests/camera3/camera3test_fixtures.h
blob: e25880da22c8dc57598b4ba2f02b2f4f5603f20a (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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*
 * Copyright (C) 2013 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef __ANDROID_HAL_CAMERA3_TEST_COMMON__
#define __ANDROID_HAL_CAMERA3_TEST_COMMON__

#include <gtest/gtest.h>
#include <hardware/hardware.h>
#include <hardware/camera3.h>

namespace tests {

static const int kMmaxCams = 2;
static const uint16_t kVersion3_0 = HARDWARE_MODULE_API_VERSION(3, 0);

class Camera3Test : public testing::Test {
 public:
    Camera3Test() :
        num_cams_(0),
        cam_module_(NULL) {}
    ~Camera3Test() {}
 protected:
    virtual void SetUp() {
        const hw_module_t *hw_module = NULL;
        ASSERT_EQ(0, hw_get_module(CAMERA_HARDWARE_MODULE_ID, &hw_module))
                    << "Can't get camera module";
        ASSERT_TRUE(NULL != hw_module)
                    << "hw_get_module didn't return a valid camera module";

        cam_module_ = reinterpret_cast<const camera_module_t*>(hw_module);
        ASSERT_TRUE(NULL != cam_module_->get_number_of_cameras)
                    << "get_number_of_cameras is not implemented";
        num_cams_ = cam_module_->get_number_of_cameras();
    }
    int num_cams() { return num_cams_; }
    const camera_module_t * cam_module() { return cam_module_; }
 private:
    int num_cams_;
    const camera_module_t *cam_module_;
};

}  // namespace tests

#endif  // __ANDROID_HAL_CAMERA3_TEST_COMMON__