Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove starboard/common/file usage above Starboard. #3412

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 11 additions & 17 deletions chrome/updater/utils_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@

#include <vector>

#include "base/files/file.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/strings/strcat.h"
#include "base/values.h"
#include "gmock/gmock.h"
#include "starboard/common/file.h"
#include "starboard/directory.h"
#include "starboard/extension/installation_manager.h"
#include "starboard/file.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace cobalt {
Expand Down Expand Up @@ -114,26 +114,22 @@ class UtilsTest : public testing::Test {
}

void TearDown() override {
ASSERT_TRUE(starboard::SbFileDeleteRecursive(temp_dir_path_.data(), true));
ASSERT_TRUE(base::DeletePathRecursively(base::FilePath(temp_dir_path_.data())));
}

void CreateManifest(const char* content, const std::string& directory) {
std::string manifest_path =
base::StrCat({directory, kSbFileSepString, kEvergreenManifestFilename});
SbFile sb_file =
SbFileOpen(manifest_path.c_str(), kSbFileOpenAlways | kSbFileRead,
nullptr, nullptr);
ASSERT_TRUE(SbFileIsValid(sb_file));
ASSERT_TRUE(SbFileClose(sb_file));

ASSERT_TRUE(
SbFileAtomicReplace(manifest_path.c_str(), content, strlen(content)));
base::File file(base::FilePath(manifest_path),
base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE);
ASSERT_TRUE(file.IsValid());
ASSERT_TRUE(file.WriteAtCurrentPos(content, strlen(content)) == strlen(content));
}

void DeleteManifest(const std::string& directory) {
std::string manifest_path =
base::StrCat({directory, kSbFileSepString, kEvergreenManifestFilename});
ASSERT_TRUE(SbFileDelete(manifest_path.c_str()));
ASSERT_TRUE(base::DeleteFile(base::FilePath(manifest_path.c_str())));
}

std::string GetLibraryPath(const std::string& name,
Expand All @@ -147,18 +143,16 @@ class UtilsTest : public testing::Test {
void CreateEmptyLibrary(const std::string& name,
const std::string& installation_path) {
std::string lib_path = GetLibraryPath(name, installation_path);
SbFile sb_file = SbFileOpen(
lib_path.c_str(), kSbFileOpenAlways | kSbFileRead, nullptr, nullptr);
ASSERT_TRUE(SbFileIsValid(sb_file));
ASSERT_TRUE(SbFileClose(sb_file));
base::File file(base::FilePath(lib_path), base::File::FLAG_OPEN_ALWAYS | base::File::FLAG_READ);
ASSERT_TRUE(file.IsValid());
}

void DeleteLibrary(const std::string& name,
const std::string& installation_path) {
std::string lib_path = GetLibraryPath(name, installation_path);
struct stat file_info;
ASSERT_TRUE(stat(lib_path.c_str(), &file_info) == 0);
ASSERT_TRUE(SbFileDelete(lib_path.c_str()));
ASSERT_TRUE(base::DeletePathRecursively(base::FilePath(lib_path.c_str())));
}

std::vector<char> temp_dir_path_;
Expand Down
Loading