Add basic image snapshot test case
Also rework the stream_renderer_snapshot_save API. We are planning to
rework stream_renderer_snapshot_save again later, because crosvm and
AEMU has different requirements for its format.
Bug: 294277842
Test: GfxstreamEnd2EndVkSnapshotImageTest
Change-Id: I6d4bde85b4f5b63b24561f9db818d6efa74f4353
diff --git a/common/end2end/GfxstreamEnd2EndVkSnapshotBasicTests.cpp b/common/end2end/GfxstreamEnd2EndVkSnapshotBasicTests.cpp
index dd27f22..544aa13 100644
--- a/common/end2end/GfxstreamEnd2EndVkSnapshotBasicTests.cpp
+++ b/common/end2end/GfxstreamEnd2EndVkSnapshotBasicTests.cpp
@@ -15,12 +15,6 @@
#include <string>
#include "GfxstreamEnd2EndTests.h"
-#include "aemu/base/files/StdioStream.h"
-#include "gfxstream/virtio-gpu-gfxstream-renderer-goldfish.h"
-#include "host-common/feature_control.h"
-#include "snapshot/TextureLoader.h"
-#include "snapshot/TextureSaver.h"
-#include "snapshot/common.h"
namespace gfxstream {
namespace tests {
@@ -31,24 +25,7 @@
TEST_P(GfxstreamEnd2EndVkSnapshotBasicTest, BasicSaveLoad) {
auto [instance, physicalDevice, device, queue, queueFamilyIndex] =
VK_ASSERT(SetUpTypicalVkTestEnvironment());
- std::string snapshotFileName = testing::TempDir() + "snapshot.bin";
- std::string textureFileName = testing::TempDir() + "texture.bin";
- std::unique_ptr<android::base::StdioStream> stream(new android::base::StdioStream(
- fopen(snapshotFileName.c_str(), "wb"), android::base::StdioStream::kOwner));
- android::snapshot::ITextureSaverPtr textureSaver(
- new android::snapshot::TextureSaver(android::base::StdioStream(
- fopen(textureFileName.c_str(), "wb"), android::base::StdioStream::kOwner)));
- stream_renderer_snapshot_presave_pause();
- stream_renderer_snapshot_save(stream.get(), &textureSaver);
- stream.reset();
- textureSaver.reset();
- stream.reset(new android::base::StdioStream(fopen(snapshotFileName.c_str(), "rb"),
- android::base::StdioStream::kOwner));
- android::snapshot::ITextureLoaderPtr textureLoader(
- new android::snapshot::TextureLoader(android::base::StdioStream(
- fopen(textureFileName.c_str(), "rb"), android::base::StdioStream::kOwner)));
- stream_renderer_snapshot_load(stream.get(), &textureLoader);
- stream_renderer_snapshot_postsave_resume_for_testing();
+ SnapshotSaveAndLoad();
}
INSTANTIATE_TEST_CASE_P(GfxstreamEnd2EndTests, GfxstreamEnd2EndVkSnapshotBasicTest,