This source file includes following definitions.
- SetSessionNameAndQuit
- TEST_F
- TEST_F
- TEST_F
- TEST_F
#include <string>
#include "base/bind.h"
#include "base/message_loop/message_loop.h"
#include "base/sys_info.h"
#include "sync/util/get_session_name.h"
#include "testing/gtest/include/gtest/gtest.h"
#if defined(OS_CHROMEOS)
#include "base/command_line.h"
#include "chromeos/chromeos_switches.h"
#endif
namespace syncer {
namespace {
class GetSessionNameTest : public ::testing::Test {
public:
void SetSessionNameAndQuit(const std::string& session_name) {
session_name_ = session_name;
message_loop_.Quit();
}
protected:
base::MessageLoop message_loop_;
std::string session_name_;
};
TEST_F(GetSessionNameTest, GetSessionNameSynchronously) {
const std::string& session_name = GetSessionNameSynchronouslyForTesting();
EXPECT_FALSE(session_name.empty());
}
#if defined(OS_CHROMEOS)
TEST_F(GetSessionNameTest, GetSessionNameSynchronouslyChromebook) {
const char* kLsbRelease = "CHROMEOS_RELEASE_BOARD=lumpy-signed-mp-v2keys\n";
base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease, base::Time());
const std::string& session_name = GetSessionNameSynchronouslyForTesting();
EXPECT_EQ("Chromebook", session_name);
}
TEST_F(GetSessionNameTest, GetSessionNameSynchronouslyChromebox) {
const char* kLsbRelease = "CHROMEOS_RELEASE_BOARD=stumpy-signed-mp-v2keys\n";
base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease, base::Time());
const std::string& session_name = GetSessionNameSynchronouslyForTesting();
EXPECT_EQ("Chromebox", session_name);
}
#endif
TEST_F(GetSessionNameTest, GetSessionName) {
GetSessionName(message_loop_.message_loop_proxy(),
base::Bind(&GetSessionNameTest::SetSessionNameAndQuit,
base::Unretained(this)));
message_loop_.Run();
EXPECT_EQ(session_name_, GetSessionNameSynchronouslyForTesting());
}
}
}