#include "chrome/updater/test/unit_test_util.h"
#include <optional>
#include <string>
#include <vector>
#include "base/base_paths.h"
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/logging.h"
#include "base/path_service.h"
#include "base/process/launch.h"
#include "base/process/process.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/synchronization/waitable_event.h"
#include "base/test/test_timeouts.h"
#include "build/build_config.h"
#include "chrome/updater/test/integration_tests_impl.h"
#include "chrome/updater/test/test_scope.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/re2/src/re2/re2.h"
#if BUILDFLAG(IS_WIN)
#include <windows.h>
#include "base/strings/string_number_conversions_win.h"
#include "chrome/updater/util/win_util.h"
#include "chrome/updater/win/test/test_executables.h"
#include "chrome/updater/win/test/test_strings.h"
#endif
namespace updater::test {
namespace {
std::string ToString(const std::string& s) { … }
std::string ToString(const std::wstring& s) { … }
}
TEST(UnitTestUtil, ToString) { … }
TEST(UnitTestUtil, Processes) { … }
TEST(UnitTestUtil, GetTestName) { … }
TEST(UnitTestUtil, DISABLED_PrintTestTimeouts) { … }
TEST(UnitTestUtil, DeleteFileAndEmptyParentDirectories) { … }
#if BUILDFLAG(IS_WIN)
TEST(UnitTestUtil, FindProcesses) {
base::CommandLine command_line = GetTestProcessCommandLine(
GetUpdaterScopeForTesting(), test::GetTestName());
EventHolder event_holder(CreateWaitableEventForTest());
command_line.AppendSwitchNative(kTestEventToWaitOn, event_holder.name);
const base::Process process = base::LaunchProcess(command_line, {});
ASSERT_TRUE(process.IsValid());
EXPECT_TRUE(test::WaitFor([&] { return process.IsRunning(); }));
EXPECT_EQ(test::FindProcesses(kTestProcessExecutableName).size(), 1U);
event_holder.event.Signal();
EXPECT_TRUE(test::WaitFor([&] { return !process.IsRunning(); }));
EXPECT_TRUE(test::FindProcesses(kTestProcessExecutableName).empty());
}
#endif
}