Commit 4abd132a authored by Joshua Pawlicki's avatar Joshua Pawlicki Committed by Commit Bot

Updater: add mode checking integration test.

Bug: 1098935
Change-Id: I50b9730d6c63544192a93dad273ffd04ed12be67
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2346548
Commit-Queue: Joshua Pawlicki <waffles@chromium.org>
Reviewed-by: default avatarSorin Jianu <sorin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#799800}
parent f6fa5f43
...@@ -5,13 +5,33 @@ ...@@ -5,13 +5,33 @@
#include "chrome/updater/test/integration_tests.h" #include "chrome/updater/test/integration_tests.h"
#include "base/test/task_environment.h" #include "base/test/task_environment.h"
#include "build/build_config.h" #include "chrome/updater/prefs.h"
#include "chrome/updater/updater_version.h"
#include "chrome/updater/util.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
namespace updater { namespace updater {
namespace test { namespace test {
// The project's position is that component builds are not portable outside of
// the build directory. Therefore, installation of component builds is not
// expected to work and these tests do not run on component builders.
// See crbug.com/1112527.
#if !defined(COMPONENT_BUILD)
namespace {
void ExpectActiveVersion(std::string expected) {
EXPECT_EQ(CreateGlobalPrefs()->GetActiveVersion(), expected);
}
void ExpectQualified() {
EXPECT_TRUE(CreateLocalPrefs()->GetQualified());
}
} // namespace
class IntegrationTest : public ::testing::Test { class IntegrationTest : public ::testing::Test {
protected: protected:
void SetUp() override { void SetUp() override {
...@@ -34,6 +54,19 @@ TEST_F(IntegrationTest, InstallUninstall) { ...@@ -34,6 +54,19 @@ TEST_F(IntegrationTest, InstallUninstall) {
Uninstall(); Uninstall();
} }
TEST_F(IntegrationTest, InstallAndPromote) {
Install();
ExpectInstalled();
ExpectActiveVersion("0");
RunWake(0); // Candidate qualifies and promotes to active.
ExpectQualified();
ExpectActiveVersion(UPDATER_VERSION_STRING);
ExpectActive();
Uninstall();
}
#endif // !defined(COMPONENT_BUILD)
} // namespace test } // namespace test
} // namespace updater } // namespace updater
...@@ -28,15 +28,16 @@ void Install(); ...@@ -28,15 +28,16 @@ void Install();
// Expect that the updater is installed on the system and the launchd tasks // Expect that the updater is installed on the system and the launchd tasks
// are updated correctly. // are updated correctly.
void ExpectActive(); void ExpectActive();
//
// Make the candidate updater version active.
void PromoteCandidate();
// Uninstall the updater. If the updater was installed during the test, it // Uninstall the updater. If the updater was installed during the test, it
// should be uninstalled before the end of the test to avoid having an actual // should be uninstalled before the end of the test to avoid having an actual
// live updater on the machine that ran the test. // live updater on the machine that ran the test.
void Uninstall(); void Uninstall();
// Run the wake client and wait for it to exit. Assert that it exits with
// |exit_code|. The server should exit a few seconds after.
void RunWake(int exit_code);
} // namespace test } // namespace test
} // namespace updater } // namespace updater
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "chrome/updater/constants.h" #include "chrome/updater/constants.h"
#include "chrome/updater/mac/xpc_service_names.h" #include "chrome/updater/mac/xpc_service_names.h"
#include "chrome/updater/updater_version.h" #include "chrome/updater/updater_version.h"
#include "chrome/updater/util.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
namespace updater { namespace updater {
...@@ -106,6 +107,16 @@ void ExpectActive() { ...@@ -106,6 +107,16 @@ void ExpectActive() {
CopyServiceLaunchdName())); CopyServiceLaunchdName()));
} }
void RunWake(int expected_exit_code) {
const base::FilePath path = GetExecutablePath();
ASSERT_FALSE(path.empty());
base::CommandLine command_line(path);
command_line.AppendSwitch(kWakeSwitch);
int exit_code = -1;
ASSERT_TRUE(Run(command_line, &exit_code));
EXPECT_EQ(exit_code, expected_exit_code);
}
void Uninstall() { void Uninstall() {
const base::FilePath path = GetExecutablePath(); const base::FilePath path = GetExecutablePath();
ASSERT_FALSE(path.empty()); ASSERT_FALSE(path.empty());
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "base/synchronization/waitable_event.h" #include "base/synchronization/waitable_event.h"
#include "base/task/task_traits.h" #include "base/task/task_traits.h"
#include "base/task/thread_pool.h" #include "base/task/thread_pool.h"
#include "chrome/updater/constants.h"
#include "chrome/updater/updater_version.h" #include "chrome/updater/updater_version.h"
#include "chrome/updater/util.h" #include "chrome/updater/util.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
...@@ -105,6 +106,23 @@ void ExpectInstalled() { ...@@ -105,6 +106,23 @@ void ExpectInstalled() {
EXPECT_TRUE(base::PathExists(GetProductPath())); EXPECT_TRUE(base::PathExists(GetProductPath()));
} }
void ExpectActive() {
// TODO(crbug.com/1062288): Assert that COM interfaces point to this version.
// Files must exist on the file system.
EXPECT_TRUE(base::PathExists(GetProductPath()));
}
void RunWake(int expected_exit_code) {
const base::FilePath path = GetExecutablePath();
ASSERT_FALSE(path.empty());
base::CommandLine command_line(path);
command_line.AppendSwitch(kWakeSwitch);
int exit_code = -1;
ASSERT_TRUE(Run(command_line, &exit_code));
EXPECT_EQ(exit_code, expected_exit_code);
}
void Install() { void Install() {
int exit_code = -1; int exit_code = -1;
ASSERT_TRUE(Run(base::CommandLine(GetInstallerPath()), &exit_code)); ASSERT_TRUE(Run(base::CommandLine(GetInstallerPath()), &exit_code));
......
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