summaryrefslogtreecommitdiffstats
path: root/tests/camera2/CameraModuleFixture.h
diff options
context:
space:
mode:
authorIgor Murashkin <iam@google.com>2012-11-06 17:02:54 -0800
committerIgor Murashkin <iam@google.com>2012-11-27 11:38:06 -0800
commiteab33fc589a8e1ca04f5703b5f1ace69f8ff9aea (patch)
treeaa511cddad9a1643fec806ed54e198923b4fcc65 /tests/camera2/CameraModuleFixture.h
parent192e51c92a34645b5e6e864d9ba65b245bd37c2b (diff)
downloadhardware_libhardware-eab33fc589a8e1ca04f5703b5f1ace69f8ff9aea.zip
hardware_libhardware-eab33fc589a8e1ca04f5703b5f1ace69f8ff9aea.tar.gz
hardware_libhardware-eab33fc589a8e1ca04f5703b5f1ace69f8ff9aea.tar.bz2
Camera2: Tests -- Fork each test before executing it
Use CAMERA2_TEST_FORKING_DISABLED=1 environment variable to override this behavior (e.g. when wanting to attach gdb to the test app). Change-Id: Ib639885bdb827fc2415c878cbcb1b2d84dff687b
Diffstat (limited to 'tests/camera2/CameraModuleFixture.h')
-rw-r--r--tests/camera2/CameraModuleFixture.h19
1 files changed, 17 insertions, 2 deletions
diff --git a/tests/camera2/CameraModuleFixture.h b/tests/camera2/CameraModuleFixture.h
index f000fdf..d604ff7 100644
--- a/tests/camera2/CameraModuleFixture.h
+++ b/tests/camera2/CameraModuleFixture.h
@@ -14,6 +14,9 @@
* limitations under the License.
*/
+#ifndef __ANDROID_HAL_CAMERA2_TESTS_MODULE_FIXTURE__
+#define __ANDROID_HAL_CAMERA2_TESTS_MODULE_FIXTURE__
+
#include <gtest/gtest.h>
#include "hardware/hardware.h"
@@ -21,6 +24,7 @@
#include "Camera2Device.h"
#include "camera2_utils.h"
+#include "TestExtensions.h"
namespace android {
namespace camera2 {
@@ -30,18 +34,24 @@ template <bool InfoQuirk = false>
struct CameraModuleFixture {
CameraModuleFixture(int CameraID = -1) {
+ TEST_EXTENSION_FORKING_CONSTRUCTOR;
+
mCameraID = CameraID;
SetUp();
}
~CameraModuleFixture() {
+ TEST_EXTENSION_FORKING_DESTRUCTOR;
+
TearDown();
}
private:
void SetUp() {
+ TEST_EXTENSION_FORKING_SET_UP;
+
ASSERT_LE(0, hw_get_module(CAMERA_HARDWARE_MODULE_ID,
(const hw_module_t **)&mModule)) << "Could not load camera module";
ASSERT_NE((void*)0, mModule);
@@ -58,14 +68,18 @@ private:
}
void TearDown() {
+ TEST_EXTENSION_FORKING_TEAR_DOWN;
+
TearDownMixin();
/* important: device must be destructed before closing module,
since it calls back into HAL */
mDevice.clear();
- ASSERT_EQ(0, HWModuleHelpers::closeModule(&mModule->common))
- << "Failed to close camera HAL module";
+ if (!TEST_EXTENSION_FORKING_ENABLED) {
+ ASSERT_EQ(0, HWModuleHelpers::closeModule(&mModule->common))
+ << "Failed to close camera HAL module";
+ }
}
void SetUpMixin() {
@@ -105,3 +119,4 @@ private:
}
}
+#endif