diff options
author | Lukasz Juszkiewicz <lukasz.juszkiewicz@bmw-carit.de> | 2014-04-30 18:15:30 +0200 |
---|---|---|
committer | Timo Lotterbach <timo.lotterbach@bmw-carit.de> | 2014-05-13 13:33:49 +0200 |
commit | 7035a0c038766aa791a99e88d3365215961b8364 (patch) | |
tree | 4ed2c1168492281af484d1fcba154fcb84c3cb09 | |
parent | 72c07ee8797ee377a0055a3ca30170defd877b91 (diff) | |
download | wayland-ivi-extension-7035a0c038766aa791a99e88d3365215961b8364.tar.gz |
tests: take screenshot
Signed-off-by: Lukasz Juszkiewicz <lukasz.juszkiewicz@bmw-carit.de>
-rw-r--r-- | ivi-layermanagement-api/test/ilm_control_test.cpp | 104 |
1 files changed, 100 insertions, 4 deletions
diff --git a/ivi-layermanagement-api/test/ilm_control_test.cpp b/ivi-layermanagement-api/test/ilm_control_test.cpp index 0836571..fbc03b7 100644 --- a/ivi-layermanagement-api/test/ilm_control_test.cpp +++ b/ivi-layermanagement-api/test/ilm_control_test.cpp @@ -925,20 +925,116 @@ TEST_F(IlmCommandTest, ilm_getPropertiesOfSurface_InvalidInput) { } TEST_F(IlmCommandTest, ilm_takeScreenshot) { + char* outputFile = "/tmp/test.bmp"; // make sure the file is not there before - FILE* f = fopen("/tmp/test.bmp", "r"); + FILE* f = fopen(outputFile, "r"); if (f!=NULL){ fclose(f); - int result = remove("/tmp/test.bmp"); + int result = remove(outputFile); ASSERT_EQ(0, result); } - ASSERT_EQ(ILM_SUCCESS, ilm_takeScreenshot(0, "/tmp/test.bmp")); + ASSERT_EQ(ILM_SUCCESS, ilm_takeScreenshot(0, outputFile)); sleep(1); - f = fopen("/tmp/test.bmp", "r"); + f = fopen(outputFile, "r"); ASSERT_TRUE(f!=NULL); fclose(f); + remove(outputFile); +} + +TEST_F(IlmCommandTest, ilm_takeScreenshot_InvalidInputs) { + char* outputFile = "/tmp/test.bmp"; + // make sure the file is not there before + FILE* f = fopen(outputFile, "r"); + if (f!=NULL){ + fclose(f); + ASSERT_EQ(0, remove(outputFile)); + } + + // try to dump an non-existing screen + ASSERT_NE(ILM_SUCCESS, ilm_takeScreenshot(0xdeadbeef, outputFile)); + + // make sure, no screen dump file was created for invalid screen + ASSERT_NE(0, remove(outputFile)); +} + +TEST_F(IlmCommandTest, ilm_takeLayerScreenshot) { + char* outputFile = "/tmp/test.bmp"; + // make sure the file is not there before + FILE* f = fopen(outputFile, "r"); + if (f!=NULL){ + fclose(f); + int result = remove(outputFile); + ASSERT_EQ(0, result); + } + + t_ilm_layer layer = 0xbeef; + ASSERT_EQ(ILM_SUCCESS, ilm_layerCreateWithDimension(&layer, 800, 480)); + ASSERT_EQ(ILM_SUCCESS, ilm_commitChanges()); + ASSERT_EQ(ILM_SUCCESS, ilm_takeLayerScreenshot(outputFile, layer)); + + sleep(1); + f = fopen(outputFile, "r"); + ASSERT_TRUE(f!=NULL); + fclose(f); + remove(outputFile); + ASSERT_EQ(ILM_SUCCESS, ilm_layerRemove(layer)); +} + +TEST_F(IlmCommandTest, ilm_takeLayerScreenshot_InvalidInputs) { + char* outputFile = "/tmp/test.bmp"; + // make sure the file is not there before + FILE* f = fopen(outputFile, "r"); + if (f!=NULL){ + fclose(f); + ASSERT_EQ(0, remove(outputFile)); + } + + // try to dump an non-existing screen + ASSERT_NE(ILM_SUCCESS, ilm_takeLayerScreenshot(outputFile, 0xdeadbeef)); + + // make sure, no screen dump file was created for invalid screen + ASSERT_NE(0, remove(outputFile)); +} + +TEST_F(IlmCommandTest, ilm_takeSurfaceScreenshot) { + char* outputFile = "/tmp/test.bmp"; + // make sure the file is not there before + FILE* f = fopen(outputFile, "r"); + if (f!=NULL){ + fclose(f); + int result = remove(outputFile); + ASSERT_EQ(0, result); + } + + t_ilm_surface surface = 0xbeef; + ASSERT_EQ(ILM_SUCCESS, ilm_surfaceCreate((t_ilm_nativehandle)wlSurface, 0, 0, ILM_PIXELFORMAT_RGBA_8888, &surface)); + ASSERT_EQ(ILM_SUCCESS, ilm_commitChanges()); + ASSERT_EQ(ILM_SUCCESS, ilm_takeSurfaceScreenshot(outputFile, surface)); + + sleep(1); + f = fopen(outputFile, "r"); + ASSERT_TRUE(f!=NULL); + fclose(f); + remove(outputFile); + ASSERT_EQ(ILM_SUCCESS, ilm_surfaceRemove(surface)); +} + +TEST_F(IlmCommandTest, ilm_takeSurfaceScreenshot_InvalidInputs) { + char* outputFile = "/tmp/test.bmp"; + // make sure the file is not there before + FILE* f = fopen(outputFile, "r"); + if (f!=NULL){ + fclose(f); + ASSERT_EQ(0, remove(outputFile)); + } + + // try to dump an non-existing screen + ASSERT_NE(ILM_SUCCESS, ilm_takeSurfaceScreenshot(outputFile, 0xdeadbeef)); + + // make sure, no screen dump file was created for invalid screen + ASSERT_NE(0, remove(outputFile)); } TEST_F(IlmCommandTest, ilm_surfaceGetPixelformat) { |