#include "chromecast/base/process_utils.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace chromecast {
TEST(ProcessUtilsTest, SimpleProcess) {
std::vector<std::string> args;
args.push_back("echo");
args.push_back("Hello World");
std::string stdout_result;
ASSERT_TRUE(GetAppOutput(args, &stdout_result));
EXPECT_EQ("Hello World\n", stdout_result);
}
TEST(ProcessUtilsTest, InvalidCommand) {
std::vector<std::string> args;
args.push_back("invalid_command");
std::string stdout_result;
ASSERT_FALSE(GetAppOutput(args, &stdout_result));
ASSERT_TRUE(stdout_result.empty());
}
TEST(ProcessUtilsTest, ProcessReturnsError) {
std::vector<std::string> args;
args.push_back("cd");
args.push_back("path/to/invalid/directory");
args.push_back("2>&1");
std::string stderr_result;
ASSERT_FALSE(GetAppOutput(args, &stderr_result));
ASSERT_FALSE(stderr_result.empty());
}
}