Igor Murashkin | 634a515 | 2013-02-20 17:15:11 -0800 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (C) 2013 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 <gtest/gtest.h> |
| 18 | #include <iostream> |
| 19 | |
| 20 | #include "Camera.h" |
| 21 | #include "ProCamera.h" |
| 22 | |
| 23 | namespace android { |
| 24 | namespace camera2 { |
| 25 | namespace tests { |
| 26 | namespace client { |
| 27 | |
| 28 | #define CAMERA_ID 0 |
| 29 | #define TEST_DEBUGGING 0 |
| 30 | |
| 31 | #if TEST_DEBUGGING |
| 32 | #define dout std::cerr |
| 33 | #else |
| 34 | #define dout if (0) std::cerr |
| 35 | #endif |
| 36 | |
| 37 | class ProCameraTest : public ::testing::Test { |
| 38 | |
| 39 | virtual void SetUp() { |
| 40 | mCamera = ProCamera::connect(CAMERA_ID); |
| 41 | ASSERT_NE((void*)NULL, mCamera.get()); |
| 42 | } |
| 43 | |
| 44 | virtual void TearDown() { |
| 45 | ASSERT_NE((void*)NULL, mCamera.get()); |
| 46 | mCamera->disconnect(); |
| 47 | } |
| 48 | |
| 49 | protected: |
| 50 | sp<ProCamera> mCamera; |
| 51 | }; |
| 52 | |
| 53 | TEST_F(ProCameraTest, Locking) { |
| 54 | |
| 55 | if (HasFatalFailure()) { |
| 56 | return; |
| 57 | } |
| 58 | |
| 59 | status_t res = mCamera->exclusiveTryLock(); |
| 60 | |
| 61 | EXPECT_EQ(OK, res); |
| 62 | } |
| 63 | |
| 64 | } |
| 65 | } |
| 66 | } |
| 67 | } |
| 68 | |