Commit 3f64588b authored by Joshua Pawlicki's avatar Joshua Pawlicki Committed by Commit Bot

Run updater integration tests with the developer key overrides.

Bug: 1119671
Change-Id: I3343d2d2520ba2cbea13ee9eae250a292eabe466
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2366666
Commit-Queue: Joshua Pawlicki <waffles@chromium.org>
Auto-Submit: Joshua Pawlicki <waffles@chromium.org>
Reviewed-by: default avatarSorin Jianu <sorin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#800709}
parent b9189597
......@@ -37,6 +37,7 @@ class IntegrationTest : public ::testing::Test {
void SetUp() override {
Clean();
ExpectClean();
EnterTestMode();
}
void TearDown() override {
......
......@@ -19,6 +19,9 @@ void Clean();
// test.
void ExpectClean();
// Place the updater into test mode (use local servers and disable CUP).
void EnterTestMode();
// Expect that the updater is installed on the system.
void ExpectInstalled();
......
......@@ -67,6 +67,15 @@ void Clean() {
EXPECT_TRUE(Launchd::GetInstance()->DeletePlist(
Launchd::User, Launchd::Agent, updater::CopyServiceLaunchdName()));
EXPECT_TRUE(base::DeletePathRecursively(GetDataDirPath()));
@autoreleasepool {
NSUserDefaults* userDefaults = [NSUserDefaults standardUserDefaults];
[userDefaults
removeObjectForKey:[NSString stringWithUTF8String:kDevOverrideKeyUrl]];
[userDefaults
removeObjectForKey:[NSString
stringWithUTF8String:kDevOverrideKeyUseCUP]];
}
}
void ExpectClean() {
......@@ -81,6 +90,18 @@ void ExpectClean() {
EXPECT_FALSE(base::PathExists(GetDataDirPath()));
}
void EnterTestMode() {
// TODO(crbug.com/1119857): Point this to an actual fake server.
@autoreleasepool {
NSUserDefaults* userDefaults = [NSUserDefaults standardUserDefaults];
[userDefaults setURL:[NSURL URLWithString:@"http://localhost:8367"]
forKey:[NSString stringWithUTF8String:kDevOverrideKeyUrl]];
[userDefaults
setBool:NO
forKey:[NSString stringWithUTF8String:kDevOverrideKeyUseCUP]];
}
}
void ExpectInstalled() {
// Files must exist on the file system.
EXPECT_TRUE(base::PathExists(GetProductPath()));
......
......@@ -8,12 +8,15 @@
#include "base/path_service.h"
#include "base/process/launch.h"
#include "base/process/process.h"
#include "base/strings/utf_string_conversions.h"
#include "base/synchronization/waitable_event.h"
#include "base/task/task_traits.h"
#include "base/task/thread_pool.h"
#include "base/win/registry.h"
#include "chrome/updater/constants.h"
#include "chrome/updater/updater_version.h"
#include "chrome/updater/util.h"
#include "chrome/updater/win/constants.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace updater {
......@@ -73,6 +76,8 @@ base::FilePath GetDataDirPath() {
void Clean() {
// TODO(crbug.com/1062288): Delete the Client / ClientState registry keys.
base::win::RegKey(HKEY_LOCAL_MACHINE, L"", KEY_SET_VALUE)
.DeleteKey(UPDATE_DEV_KEY);
// TODO(crbug.com/1062288): Delete the COM server items.
// TODO(crbug.com/1062288): Delete the COM service items.
// TODO(crbug.com/1062288): Delete the COM interfaces.
......@@ -84,6 +89,7 @@ void Clean() {
void ExpectClean() {
// TODO(crbug.com/1062288): Assert there are no Client / ClientState registry
// keys.
// TODO(crbug.com/1062288): Assert there is no UpdateDev registry key.
// TODO(crbug.com/1062288): Assert there are no COM server items.
// TODO(crbug.com/1062288): Assert there are no COM service items.
// TODO(crbug.com/1062288): Assert there are no COM interfaces.
......@@ -94,6 +100,19 @@ void ExpectClean() {
EXPECT_FALSE(base::PathExists(GetDataDirPath()));
}
void EnterTestMode() {
// TODO(crbug.com/1119857): Point this to an actual fake server.
base::win::RegKey key(HKEY_LOCAL_MACHINE, L"", KEY_SET_VALUE);
ASSERT_EQ(key.Create(HKEY_LOCAL_MACHINE, UPDATE_DEV_KEY, KEY_WRITE),
ERROR_SUCCESS);
ASSERT_EQ(key.WriteValue(base::UTF8ToUTF16(kDevOverrideKeyUrl).c_str(),
L"http://localhost:8367"),
ERROR_SUCCESS);
ASSERT_EQ(key.WriteValue(base::UTF8ToUTF16(kDevOverrideKeyUseCUP).c_str(),
static_cast<DWORD>(0)),
ERROR_SUCCESS);
}
void ExpectInstalled() {
// TODO(crbug.com/1062288): Assert there are Client / ClientState registry
// keys.
......
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