2016-10-04 22:46:02 +00:00
|
|
|
// Copyright 2016 Google Inc. All rights reserved.
|
|
|
|
//
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file or at
|
|
|
|
// https://developers.google.com/open-source/licenses/bsd
|
|
|
|
|
2017-07-10 18:26:22 +00:00
|
|
|
#include "packager/file/file_util.h"
|
2016-10-04 22:46:02 +00:00
|
|
|
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
|
2018-08-06 23:11:57 +00:00
|
|
|
#include "packager/base/logging.h"
|
|
|
|
|
2016-10-04 22:46:02 +00:00
|
|
|
namespace shaka {
|
|
|
|
|
2018-08-06 23:11:57 +00:00
|
|
|
TEST(FileUtilTest, TempFilePathInDesignatedDirectory) {
|
2016-10-04 22:46:02 +00:00
|
|
|
std::string temp_file_path;
|
|
|
|
EXPECT_TRUE(TempFilePath("test", &temp_file_path));
|
|
|
|
EXPECT_EQ(temp_file_path.find("test"), 0u);
|
2018-08-06 23:11:57 +00:00
|
|
|
LOG(INFO) << "temp file path: " << temp_file_path;
|
|
|
|
}
|
2016-10-04 22:46:02 +00:00
|
|
|
|
2018-08-06 23:11:57 +00:00
|
|
|
TEST(FileUtilTest, TempFilePathInSystemTempDirectory) {
|
|
|
|
std::string temp_file_path;
|
2016-10-04 22:46:02 +00:00
|
|
|
EXPECT_TRUE(TempFilePath("", &temp_file_path));
|
|
|
|
// temp_file_path should be created in a system specific temp directory.
|
2018-08-06 23:11:57 +00:00
|
|
|
LOG(INFO) << "temp file path: " << temp_file_path;
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(FileUtilTest, TempFilePathCalledTwice) {
|
|
|
|
const char kTempDir[] = "/test/";
|
|
|
|
std::string temp_file_path1;
|
|
|
|
std::string temp_file_path2;
|
|
|
|
ASSERT_TRUE(TempFilePath(kTempDir, &temp_file_path1));
|
|
|
|
ASSERT_TRUE(TempFilePath(kTempDir, &temp_file_path2));
|
|
|
|
ASSERT_NE(temp_file_path1, temp_file_path2);
|
|
|
|
LOG(INFO) << "temp file path1: " << temp_file_path1;
|
|
|
|
LOG(INFO) << "temp file path2: " << temp_file_path2;
|
2016-10-04 22:46:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace shaka
|