1/*
2 * Copyright (C) 2012 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#ifndef __ANDROID_HAL_CAMERA2_TESTS_EXTENSIONS__
18#define __ANDROID_HAL_CAMERA2_TESTS_EXTENSIONS__
19
20#include "TestForkerEventListener.h"
21#include "TestSettings.h"
22
23// Use at the beginning of each Test::SetUp() impl
24#define TEST_EXTENSION_FORKING_SET_UP                                       \
25    do {                                                                    \
26        if (TEST_EXTENSION_FORKING_ENABLED) {                               \
27            if (!TestForkerEventListener::mIsForked) {                      \
28                return;                                                     \
29            }                                                               \
30        }                                                                   \
31    } while (false)                                                         \
32
33// Use at the beginning of each Test::TearDown() impl
34#define TEST_EXTENSION_FORKING_TEAR_DOWN   TEST_EXTENSION_FORKING_SET_UP
35
36// Use at the beginning of each Test::Test constructor
37#define TEST_EXTENSION_FORKING_CONSTRUCTOR TEST_EXTENSION_FORKING_SET_UP
38
39// Use at the beginning of each Test::~Test destructor
40#define TEST_EXTENSION_FORKING_DESTRUCTOR  TEST_EXTENSION_FORKING_TEAR_DOWN
41
42// Use at the beginning of each test body, e.g. TEST(x,y), TEST_F(x,y), etc
43#define TEST_EXTENSION_FORKING_INIT                                         \
44    do {                                                                    \
45        TEST_EXTENSION_FORKING_SET_UP;                                      \
46        if (HasFatalFailure()) return;                                      \
47    } while(false)                                                          \
48
49// Are we running each test by forking it?
50#define TEST_EXTENSION_FORKING_ENABLED                                      \
51    (android::camera2::tests::TestSettings::ForkingEnabled())
52
53
54
55#endif
56
57