Skip to content

Commit

Permalink
Remove starboard/common/file usage above Starboard.
Browse files Browse the repository at this point in the history
b/322248208

Change-Id: I542c1da859e4ed615477887965030e4ff5bd8a9d
  • Loading branch information
iuriionishchenko committed May 31, 2024
1 parent 04a009e commit 58fbe73
Showing 1 changed file with 10 additions and 17 deletions.
27 changes: 10 additions & 17 deletions chrome/updater/utils_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@

#include <vector>

#include "base/files/file.h"
#include "base/files/file_path.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 +113,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_OPEN_TRUNCATED | base::File::FLAG_CREATE | 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())));
}

void CreateEmptyLibrary(const std::string& name,
Expand All @@ -143,16 +138,14 @@ class UtilsTest : public testing::Test {
ASSERT_TRUE(EnsureDirectoryExists(lib_path.c_str()));

lib_path = base::StrCat({lib_path, kSbFileSepString, name});
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 DeleteLibraryDirRecursively(const std::string& installation_path) {
std::string lib_path = base::StrCat(
{installation_path, kSbFileSepString, kEvergreenLibDirname});
ASSERT_TRUE(starboard::SbFileDeleteRecursive(lib_path.c_str(), false));
ASSERT_TRUE(base::DeletePathRecursively(base::FilePath(lib_path.c_str())));
}

std::vector<char> temp_dir_path_;
Expand Down

0 comments on commit 58fbe73

Please sign in to comment.