This source file includes following definitions.
- TEST
- TEST
#include <string>
#include "base/base64.h"
#include "base/file_util.h"
#include "base/files/file_path.h"
#include "base/files/scoped_temp_dir.h"
#include "chrome/test/chromedriver/chrome/status.h"
#include "chrome/test/chromedriver/util.h"
#include "testing/gtest/include/gtest/gtest.h"
TEST(UnzipSoleFile, Entry) {
base::ScopedTempDir temp_dir;
ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
std::string data;
const char* kBase64ZipEntry =
"UEsDBBQACAAIAJpyXEAAAAAAAAAAAAAAAAAEAAAAdGVzdHP2D+"
"cCAFBLBwi/wAzGBgAAAAQAAAA=";
ASSERT_TRUE(base::Base64Decode(kBase64ZipEntry, &data));
base::FilePath file;
Status status = UnzipSoleFile(temp_dir.path(), data, &file);
ASSERT_EQ(kOk, status.code()) << status.message();
std::string contents;
ASSERT_TRUE(base::ReadFileToString(file, &contents));
ASSERT_STREQ("COW\n", contents.c_str());
}
TEST(UnzipSoleFile, Archive) {
base::ScopedTempDir temp_dir;
ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
std::string data;
const char* kBase64ZipArchive =
"UEsDBBQAAAAAAMROi0K/wAzGBAAAAAQAAAADAAAAbW9vQ09XClBLAQIUAxQAAAAAAMROi0K/"
"wAzGBAAAAAQAAAADAAAAAAAAAAAAAACggQAAAABtb29QSwUGAAAAAAEAAQAxAAAAJQAAAAA"
"A";
ASSERT_TRUE(base::Base64Decode(kBase64ZipArchive, &data));
base::FilePath file;
Status status = UnzipSoleFile(temp_dir.path(), data, &file);
ASSERT_EQ(kOk, status.code()) << status.message();
std::string contents;
ASSERT_TRUE(base::ReadFileToString(file, &contents));
ASSERT_STREQ("COW\n", contents.c_str());
}