Commit c5d56c3c authored by Roger Tawa's avatar Roger Tawa Committed by Commit Bot

Update RLZ to support new Chrome OS workflows:

- generate single CAF event per device, for its lifetime
- avoid sending RLZ pings too early in the device lifetime
- do the above while respecting chromeos privacy guarantees

The exact changes are described in the PRD and design doc:

https://docs.google.com/document/d/1Q3UnTO9PSKd8oIysOSV7M5mv3x3o8pK3IaV45NL9riM/edit?usp=sharing
https://docs.google.com/document/d/1BC9O0fXCEP56T619jZTyuELrMPVO4PFRkvUEHo8dmwk/edit#

This change also fixes a bug that did not stop the ShutdownCheck() even after
completing an RLZ ping.

Bug: 820783
Change-Id: Iec2a017504fa43d7fda2db5c77a1c9de2cacff2a
Reviewed-on: https://chromium-review.googlesource.com/959601Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Reviewed-by: default avatarWenzhao (Colin) Zang <wzang@chromium.org>
Commit-Queue: Roger Tawa <rogerta@chromium.org>
Cr-Commit-Position: refs/heads/master@{#543363}
parent 053b619c
......@@ -356,6 +356,16 @@ bool IsRunningTest() {
::switches::kTestType);
}
#if BUILDFLAG(ENABLE_RLZ)
UserSessionManager::RlzInitParams CollectRlzParams() {
UserSessionManager::RlzInitParams params;
params.disabled = base::PathExists(GetRlzDisabledFlagPath());
params.time_since_oobe_completion =
chromeos::StartupUtils::GetTimeSinceOobeFlagFileCreation();
return params;
}
#endif
} // namespace
UserSessionManagerDelegate::~UserSessionManagerDelegate() {}
......@@ -652,7 +662,7 @@ void UserSessionManager::InitRlz(Profile* profile) {
FROM_HERE,
{base::MayBlock(), base::TaskPriority::BACKGROUND,
base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN},
base::Bind(&base::PathExists, GetRlzDisabledFlagPath()),
base::Bind(&CollectRlzParams),
base::Bind(&UserSessionManager::InitRlzImpl, AsWeakPtr(), profile));
#endif
}
......@@ -1581,27 +1591,32 @@ void UserSessionManager::RestoreAuthSessionImpl(
user_context_.GetAccessToken());
}
void UserSessionManager::InitRlzImpl(Profile* profile, bool disabled) {
void UserSessionManager::InitRlzImpl(Profile* profile,
const RlzInitParams& params) {
#if BUILDFLAG(ENABLE_RLZ)
PrefService* local_state = g_browser_process->local_state();
if (disabled) {
if (params.disabled) {
// Empty brand code means an organic install (no RLZ pings are sent).
google_brand::chromeos::ClearBrandForCurrentSession();
}
if (disabled != local_state->GetBoolean(prefs::kRLZDisabled)) {
if (params.disabled != local_state->GetBoolean(prefs::kRLZDisabled)) {
// When switching to RLZ enabled/disabled state, clear all recorded events.
rlz::RLZTracker::ClearRlzState();
local_state->SetBoolean(prefs::kRLZDisabled, disabled);
local_state->SetBoolean(prefs::kRLZDisabled, params.disabled);
}
// Init the RLZ library.
int ping_delay = profile->GetPrefs()->GetInteger(prefs::kRlzPingDelaySeconds);
// Negative ping delay means to send ping immediately after a first search is
// recorded.
bool send_ping_immediately = ping_delay < 0;
base::TimeDelta delay =
base::TimeDelta::FromSeconds(abs(ping_delay)) -
params.time_since_oobe_completion;
rlz::RLZTracker::SetRlzDelegate(
base::WrapUnique(new ChromeRLZTrackerDelegate));
rlz::RLZTracker::InitRlzDelayed(
user_manager::UserManager::Get()->IsCurrentUserNew(), ping_delay < 0,
base::TimeDelta::FromSeconds(abs(ping_delay)),
user_manager::UserManager::Get()->IsCurrentUserNew(),
send_ping_immediately, delay,
ChromeRLZTrackerDelegate::IsGoogleDefaultSearch(profile),
ChromeRLZTrackerDelegate::IsGoogleHomepage(profile),
ChromeRLZTrackerDelegate::IsGoogleInStartpages(profile));
......
......@@ -110,6 +110,18 @@ class UserSessionManager
SECONDARY_USER_SESSION_AFTER_CRASH,
} StartSessionType;
// Parameters to use when initializing the RLZ library. These fields need
// to be retrieved from a blocking task and this structure is used to pass
// the data.
struct RlzInitParams {
// Set to true if RLZ is disabled.
bool disabled;
// The elapsed time since the device went through the OOBE. This can
// be a very long time.
base::TimeDelta time_since_oobe_completion;
};
// Returns UserSessionManager instance.
static UserSessionManager* GetInstance();
......@@ -364,7 +376,7 @@ class UserSessionManager
void RestoreAuthSessionImpl(Profile* profile, bool restore_from_auth_cookies);
// Initializes RLZ. If |disabled| is true, RLZ pings are disabled.
void InitRlzImpl(Profile* profile, bool disabled);
void InitRlzImpl(Profile* profile, const RlzInitParams& params);
// If |user| is not a kiosk app, sets session type as seen by extensions
// feature system according to |user|'s type.
......
......@@ -44,8 +44,12 @@ ChromeRLZTrackerDelegate::~ChromeRLZTrackerDelegate() {}
void ChromeRLZTrackerDelegate::RegisterProfilePrefs(
user_prefs::PrefRegistrySyncable* registry) {
#if BUILDFLAG(ENABLE_RLZ)
#if defined(OS_CHROMEOS)
registry->RegisterIntegerPref(prefs::kRlzPingDelaySeconds, 24 * 3600);
#else
registry->RegisterIntegerPref(prefs::kRlzPingDelaySeconds, 90);
#endif
#endif
}
// static
......
......@@ -28,7 +28,11 @@ namespace {
// Maximum and minimum delay for financial ping we would allow to be set through
// master preferences. Somewhat arbitrary, may need to be adjusted in future.
#if defined(OS_CHROMEOS)
const base::TimeDelta kMaxInitDelay = base::TimeDelta::FromHours(24);
#else
const base::TimeDelta kMaxInitDelay = base::TimeDelta::FromSeconds(200);
#endif
const base::TimeDelta kMinInitDelay = base::TimeDelta::FromSeconds(20);
void RecordProductEvents(bool first_run,
......
......@@ -889,6 +889,9 @@ TEST_F(RlzLibTest, GetAccessPointRlzIsCached) {
EXPECT_STREQ(kOmniboxRlzString, base::UTF16ToUTF8(rlz).c_str());
}
#if !defined(OS_CHROMEOS)
// By design, on Chrome OS the RLZ string can only be set once. Once set,
// pings cannot change int.
TEST_F(RlzLibTest, PingUpdatesRlzCache) {
// Set dummy RLZ string.
rlz_lib::SetAccessPointRlz(RLZTracker::ChromeOmnibox(), kOmniboxRlzString);
......@@ -944,6 +947,7 @@ TEST_F(RlzLibTest, PingUpdatesRlzCache) {
EXPECT_STREQ(kNewAppListRlzString, base::UTF16ToUTF8(rlz).c_str());
#endif // !defined(OS_IOS)
}
#endif // !defined(OS_CHROMEOS)
// TODO(thakis): Reactivation doesn't exist on Mac yet.
TEST_F(RlzLibTest, ReactivationNonOrganicNonOrganic) {
......
......@@ -40,7 +40,6 @@ source_set("rlz_utils") {
if (!is_android) {
source_set("rlz_lib") {
sources = [
"chromeos/lib/machine_id_chromeos.cc",
"chromeos/lib/rlz_value_store_chromeos.cc",
"chromeos/lib/rlz_value_store_chromeos.h",
"ios/lib/machine_id_ios.cc",
......
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "rlz/lib/machine_id.h"
namespace rlz_lib {
bool GetRawMachineId(base::string16* data, int* more_data) {
// Machine IDs are not tracked for ChromeOS.
return false;
}
} // namespace rlz_lib
......@@ -46,6 +46,9 @@ base::LazyInstance<base::FilePath>::Leaky g_testing_rlz_store_path =
LAZY_INSTANCE_INITIALIZER;
base::FilePath GetRlzStorePathCommon() {
// TODO(wzang): Replace base::DIR_HOME with something that is shared by all
// profiles on the device. This location must be somewhere that is wiped
// when the device is factory reset or powerwashed.
base::FilePath homedir;
PathService::Get(base::DIR_HOME, &homedir);
return g_testing_rlz_store_path.Get().empty()
......@@ -107,6 +110,14 @@ bool RlzValueStoreChromeOS::WritePingTime(Product product, int64_t time) {
bool RlzValueStoreChromeOS::ReadPingTime(Product product, int64_t* time) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
#if defined(OS_CHROMEOS)
// TODO(wzang): make sure time is correct (check that npupdate has updated
// successfully).
// TODO(wzang): if the current time is within 7 days of the
// factory_production_date value in the RW_VPD, then return the current time.
#endif
std::string ping_time;
return rlz_store_->GetString(GetKeyName(kPingTimeKey, product), &ping_time) &&
base::StringToInt64(ping_time, time);
......@@ -120,6 +131,24 @@ bool RlzValueStoreChromeOS::ClearPingTime(Product product) {
bool RlzValueStoreChromeOS::WriteAccessPointRlz(AccessPoint access_point,
const char* new_rlz) {
#if defined(OS_CHROMEOS)
// If an access point already exists, don't overwrite it. This is to prevent
// writing cohort data for first search which is not needed in Chrome OS.
//
// There are two possible cases: either the user performs a search before the
// first ping is sent on first run, or they do not. If they do, then
// |new_rlz| contain cohorts for install and first search, but they will be
// the same. If they don't, the first time WriteAccessPointRlz() is called
// |new_rlz| will contain only install cohort. The second time it will
// contain both install and first search cohorts. Ignoring the second
// means the first search cohort will never be stored.
char dummy[kMaxRlzLength + 1];
if (ReadAccessPointRlz(access_point, dummy, arraysize(dummy)) &&
dummy[0] != 0) {
return true;
}
#endif
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
rlz_store_->SetString(
GetKeyName(kAccessPointKey, access_point), new_rlz);
......@@ -187,6 +216,13 @@ bool RlzValueStoreChromeOS::ClearAllProductEvents(Product product) {
bool RlzValueStoreChromeOS::AddStatefulEvent(Product product,
const char* event_rlz) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
#if defined(OS_CHROMEOS)
if (strcmp(event_rlz, "CAF") == 0) {
// TODO(wzang): Set rlz_first_use_ping_not_sent to 0 in RW_VPD.
}
#endif
return AddValueToList(GetKeyName(kStatefulEventKey, product),
std::make_unique<base::Value>(event_rlz));
}
......@@ -194,6 +230,20 @@ bool RlzValueStoreChromeOS::AddStatefulEvent(Product product,
bool RlzValueStoreChromeOS::IsStatefulEvent(Product product,
const char* event_rlz) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
#if defined(OS_CHROMEOS)
if (strcmp(event_rlz, "CAF") == 0) {
// TODO(wzang): If rlz_first_use_ping_not_sent exists in RW_VPD with
// value 0, then return true.
// TODO(wzang): if the current time is within 7 days of the
// factory_production_date value in the RW_VPD, then return true.
// TODO(wzang): if rlz_first_use_ping_not_sent exists in RW_VPD with
// value 1 but below the code finds |event_value| in the list, try to
// set rlz_first_use_ping_not_sent to zero in the RW_VPD. This is to try
// and fix the RW_VPD if there was an error writing to it earlier.
}
#endif
base::Value event_value(event_rlz);
base::ListValue* events_list = NULL;
return rlz_store_->GetList(GetKeyName(kStatefulEventKey, product),
......
......@@ -204,6 +204,9 @@ bool FinancialPing::SetURLRequestContext(
return true;
}
// Signal to stop the ShutdownCheck() task.
AtomicWord g_cancelShutdownCheck;
namespace {
// A waitable event used to detect when either:
......@@ -278,7 +281,11 @@ bool send_financial_ping_interrupted_for_test = false;
} // namespace
#if defined(RLZ_NETWORK_IMPLEMENTATION_CHROME_NET)
void ShutdownCheck(scoped_refptr<RefCountedWaitableEvent> event) {
if (base::subtle::Acquire_Load(&g_cancelShutdownCheck))
return;
if (!base::subtle::Acquire_Load(&g_context)) {
send_financial_ping_interrupted_for_test = true;
event->SignalShutdown();
......@@ -291,6 +298,7 @@ void ShutdownCheck(scoped_refptr<RefCountedWaitableEvent> event) {
base::BindOnce(&ShutdownCheck, event),
kInterval);
}
#endif
void PingRlzServer(std::string url,
scoped_refptr<RefCountedWaitableEvent> event) {
......@@ -417,6 +425,8 @@ bool FinancialPing::PingServer(const char* request, std::string* response) {
// wininet implementation.
auto event = base::MakeRefCounted<RefCountedWaitableEvent>();
base::subtle::Release_Store(&g_cancelShutdownCheck, 0);
base::PostTaskWithTraits(FROM_HERE, {base::TaskPriority::BACKGROUND},
base::BindOnce(&ShutdownCheck, event));
......@@ -435,6 +445,9 @@ bool FinancialPing::PingServer(const char* request, std::string* response) {
base::ScopedAllowBaseSyncPrimitives allow_base_sync_primitives;
is_signaled = event->TimedWait(base::TimeDelta::FromMinutes(5));
}
base::subtle::Release_Store(&g_cancelShutdownCheck, 1);
if (!is_signaled || event->GetResponseCode() != 200)
return false;
......
......@@ -55,6 +55,14 @@ int64_t GetSystemTimeAsInt64() {
#endif
}
#if defined(OS_CHROMEOS)
void RemoveMachineIdFromUrl(std::string* url) {
size_t id_offset = url->find("&id=");
EXPECT_NE(std::string::npos, id_offset);
url->resize(id_offset);
}
#endif
// Ping times in 100-nanosecond intervals.
const int64_t k1MinuteInterval = 60LL * 10000000LL; // 1 minute
......@@ -87,17 +95,30 @@ TEST_F(FinancialPingTest, FormRequest) {
{rlz_lib::IETB_SEARCH_BOX, rlz_lib::NO_ACCESS_POINT,
rlz_lib::NO_ACCESS_POINT};
// Don't check the machine Id on Chrome OS since a random one is generated
// each time.
std::string machine_id;
#if defined(OS_CHROMEOS)
bool got_machine_id = false;
#else
bool got_machine_id = rlz_lib::GetMachineId(&machine_id);
#endif
std::string request;
EXPECT_TRUE(rlz_lib::FinancialPing::FormRequest(rlz_lib::TOOLBAR_NOTIFIER,
points, "swg", brand, NULL, "en", false, &request));
#if defined(OS_CHROMEOS)
// Ignore the machine Id of the request URL. On Chrome OS a random Id is
// generated with each request.
RemoveMachineIdFromUrl(&request);
#endif
std::string expected_response;
base::StringAppendF(&expected_response,
"/tools/pso/ping?as=swg&brand=%s&hl=en&"
"events=I7S,W1I&rep=2&rlz=T4:TbRlzValue" DCC_PARAM
, brand);
"/tools/pso/ping?as=swg&brand=%s&hl=en&"
"events=I7S,W1I&rep=2&rlz=T4:TbRlzValue" DCC_PARAM,
brand);
if (got_machine_id)
base::StringAppendF(&expected_response, "&id=%s", machine_id.c_str());
......@@ -106,6 +127,13 @@ TEST_F(FinancialPingTest, FormRequest) {
EXPECT_TRUE(rlz_lib::SetAccessPointRlz(rlz_lib::IETB_SEARCH_BOX, ""));
EXPECT_TRUE(rlz_lib::FinancialPing::FormRequest(rlz_lib::TOOLBAR_NOTIFIER,
points, "swg", brand, "IdOk2", NULL, false, &request));
#if defined(OS_CHROMEOS)
// Ignore the machine Id of the request URL. On Chrome OS a random Id is
// generated with each request.
RemoveMachineIdFromUrl(&request);
#endif
expected_response.clear();
base::StringAppendF(&expected_response,
"/tools/pso/ping?as=swg&brand=%s&pid=IdOk2&"
......
......@@ -6,7 +6,9 @@
#include <stddef.h>
#include "base/rand_util.h"
#include "base/sha1.h"
#include "base/strings/stringprintf.h"
#include "rlz/lib/assert.h"
#include "rlz/lib/crc8.h"
#include "rlz/lib/string_utils.h"
......@@ -17,6 +19,26 @@ bool GetMachineId(std::string* machine_id) {
if (!machine_id)
return false;
#if defined(OS_CHROMEOS)
// Generate a random machine Id each time this function is called. This
// prevents the RLZ server from correlating two RLZ pings from the same
// Chrome OS device.
//
// The Id should be 50 characters long and begin with "nonce-". Generate 22
// cryptographically random bytes, then convert to a printable string using
// 2 hex digits per byte for a string of length 44 characters.
unsigned char bytes[22];
std::string str_bytes;
base::RandBytes(bytes, sizeof(bytes));
rlz_lib::BytesToString(bytes, sizeof(bytes), &str_bytes);
machine_id->clear();
base::StringAppendF(machine_id, "nonce-%s", str_bytes.c_str());
DCHECK_EQ(50u, machine_id->length());
return true;
#else
static std::string calculated_id;
static bool calculated = false;
if (calculated) {
......@@ -35,6 +57,8 @@ bool GetMachineId(std::string* machine_id) {
calculated = true;
calculated_id = *machine_id;
return true;
#endif // defined(OS_CHROMEOS)
}
namespace testing {
......
......@@ -18,3 +18,13 @@ TEST(MachineDealCodeTestMachineId, MachineId) {
EXPECT_STREQ("A341BA986A7E86840688977FCF20C86E253F00919E068B50F8",
id.c_str());
}
#if defined(OS_CHROMEOS)
TEST(MachineDealCodeTestMachineId, MachineIdIsUnique) {
std::string id1;
std::string id2;
rlz_lib::GetMachineId(&id1);
rlz_lib::GetMachineId(&id2);
EXPECT_NE(id1, id2);
}
#endif
......@@ -12,6 +12,7 @@
#include "base/macros.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/syslog_logging.h"
#include "build/build_config.h"
#include "rlz/lib/assert.h"
#include "rlz/lib/financial_ping.h"
......@@ -386,21 +387,24 @@ bool ParseFinancialPingResponse(Product product, const char* response) {
return ParsePingResponse(product, response);
}
bool SendFinancialPing(Product product, const AccessPoint* access_points,
bool SendFinancialPing(Product product,
const AccessPoint* access_points,
const char* product_signature,
const char* product_brand,
const char* product_id, const char* product_lang,
const char* product_id,
const char* product_lang,
bool exclude_machine_id) {
return SendFinancialPing(product, access_points, product_signature,
product_brand, product_id, product_lang,
exclude_machine_id, false);
}
bool SendFinancialPing(Product product, const AccessPoint* access_points,
bool SendFinancialPing(Product product,
const AccessPoint* access_points,
const char* product_signature,
const char* product_brand,
const char* product_id, const char* product_lang,
const char* product_id,
const char* product_lang,
bool exclude_machine_id,
const bool skip_time_check) {
// Create the financial ping request.
......@@ -414,11 +418,27 @@ bool SendFinancialPing(Product product, const AccessPoint* access_points,
if (!FinancialPing::IsPingTime(product, skip_time_check))
return false;
#if defined(OS_CHROMEOS)
// Write to syslog that an RLZ ping is being attempted. This is purposefully
// done via syslog so that admin and/or end users can monitor RLZ activity
// from this machine. If RLZ is turned off in crosh, these messages will
// be absent.
SYSLOG(INFO) << "Attempting to send RLZ ping brand=" << product_brand;
#endif
// Send out the ping, update the last ping time irrespective of success.
FinancialPing::UpdateLastPingTime(product);
std::string response;
if (!FinancialPing::PingServer(request.c_str(), &response))
if (!FinancialPing::PingServer(request.c_str(), &response)) {
#if defined(OS_CHROMEOS)
SYSLOG(INFO) << "Failed sending RLZ ping";
#endif
return false;
}
#if defined(OS_CHROMEOS)
SYSLOG(INFO) << "Succeeded in sending RLZ ping";
#endif
// Parse the ping response - update RLZs, clear events.
return ParsePingResponse(product, response.c_str());
......
......@@ -176,6 +176,20 @@ TEST_F(RlzLibTest, SetAccessPointRlz) {
EXPECT_STREQ("IeTbRlz", rlz_50);
}
#if defined(OS_CHROMEOS)
TEST_F(RlzLibTest, SetAccessPointRlzOnlyOnce) {
// On Chrome OS, and RLZ string can ne set only once.
char rlz_50[50];
EXPECT_TRUE(rlz_lib::SetAccessPointRlz(rlz_lib::IETB_SEARCH_BOX, "First"));
EXPECT_TRUE(rlz_lib::GetAccessPointRlz(rlz_lib::IETB_SEARCH_BOX, rlz_50, 50));
EXPECT_STREQ("First", rlz_50);
EXPECT_TRUE(rlz_lib::SetAccessPointRlz(rlz_lib::IETB_SEARCH_BOX, "Second"));
EXPECT_TRUE(rlz_lib::GetAccessPointRlz(rlz_lib::IETB_SEARCH_BOX, rlz_50, 50));
EXPECT_STREQ("First", rlz_50);
}
#endif
TEST_F(RlzLibTest, GetAccessPointRlz) {
char rlz_1[1];
char rlz_50[50];
......@@ -335,12 +349,6 @@ TEST_F(RlzLibTest, ParsePingResponse) {
EXPECT_TRUE(rlz_lib::RecordProductEvent(rlz_lib::TOOLBAR_NOTIFIER,
rlz_lib::IE_HOME_PAGE, rlz_lib::INSTALL));
EXPECT_TRUE(rlz_lib::SetAccessPointRlz(
rlz_lib::IETB_SEARCH_BOX, "TbRlzValue"));
EXPECT_TRUE(rlz_lib::ParsePingResponse(rlz_lib::TOOLBAR_NOTIFIER,
kPingResponse));
#if defined(OS_WIN)
EXPECT_TRUE(rlz_lib::MachineDealCode::Set("dcc_value"));
#endif
......@@ -360,13 +368,23 @@ TEST_F(RlzLibTest, ParsePingResponse) {
EXPECT_TRUE(rlz_lib::ParsePingResponse(rlz_lib::TOOLBAR_NOTIFIER,
kPingResponse2));
EXPECT_TRUE(rlz_lib::GetAccessPointRlz(rlz_lib::IETB_SEARCH_BOX, value, 50));
#if defined(OS_CHROMEOS)
// On Chrome OS, the RLZ string is not modified by response once set.
EXPECT_STREQ("1T4_____en__252", value);
#else
EXPECT_STREQ("1T4_____de__253", value);
#endif
const char* kPingResponse3 =
"crc32: 0\r\n"; // Good RLZ - empty response.
EXPECT_TRUE(rlz_lib::ParsePingResponse(rlz_lib::TOOLBAR_NOTIFIER,
kPingResponse3));
#if defined(OS_CHROMEOS)
// On Chrome OS, the RLZ string is not modified by response once set.
EXPECT_STREQ("1T4_____en__252", value);
#else
EXPECT_STREQ("1T4_____de__253", value);
#endif
}
// Test whether a stateful event will only be sent in financial pings once.
......@@ -931,6 +949,10 @@ TEST_F(RlzLibTest, LockAcquistionSucceedsButStoreFileCannotBeCreated) {
if (!rlz_lib::SupplementaryBranding::GetBrand().empty())
return;
// Make sure to use a brand new directory for this test, since
// RlzLibTest::SetUp() will have created a store file to setup the tests.
m_rlz_test_helper_.Reset();
// Create a directory where the rlz file is supposed to appear. This way,
// the lock file can be created successfully, but creation of the rlz file
// itself will fail.
......
......@@ -144,6 +144,16 @@ void RlzLibTestNoMachineStateHelper::TearDown() {
#endif // defined(OS_POSIX)
}
void RlzLibTestNoMachineStateHelper::Reset() {
#if defined(OS_POSIX)
ASSERT_TRUE(temp_dir_.Delete());
ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
rlz_lib::testing::SetRlzStoreDirectory(temp_dir_.GetPath());
#else
NOTREACHED();
#endif // defined(OS_POSIX)
}
void RlzLibTestNoMachineState::SetUp() {
m_rlz_test_helper_.SetUp();
}
......@@ -157,4 +167,11 @@ void RlzLibTestBase::SetUp() {
#if defined(OS_WIN)
rlz_lib::CreateMachineState();
#endif // defined(OS_WIN)
#if defined(OS_POSIX)
// Make sure the values of RLZ strings for access points used in tests start
// out not set, since on Chrome OS RLZ string can only be set once.
EXPECT_TRUE(rlz_lib::SetAccessPointRlz(rlz_lib::IETB_SEARCH_BOX, ""));
EXPECT_TRUE(rlz_lib::SetAccessPointRlz(rlz_lib::IE_HOME_PAGE, ""));
#endif // defined(OS_CHROMEOS)
}
......@@ -26,6 +26,7 @@ class RlzLibTestNoMachineStateHelper {
public:
void SetUp();
void TearDown();
void Reset();
#if defined(OS_POSIX)
base::ScopedTempDir temp_dir_;
......@@ -47,8 +48,6 @@ class RlzLibTestNoMachineState : public ::testing::Test {
class RlzLibTestBase : public RlzLibTestNoMachineState {
protected:
void SetUp() override;
RlzLibTestNoMachineStateHelper m_rlz_test_helper_;
};
#endif // RLZ_TEST_RLZ_TEST_HELPERS_H
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment