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 <[email protected]>
Reviewed-by: Sorin Jianu <[email protected]>
Cr-Commit-Position: refs/heads/master@{#799800}
diff --git a/chrome/updater/test/integration_tests.cc b/chrome/updater/test/integration_tests.cc
index 8453215..cc8443f 100644
--- a/chrome/updater/test/integration_tests.cc
+++ b/chrome/updater/test/integration_tests.cc
@@ -5,13 +5,33 @@
#include "chrome/updater/test/integration_tests.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"
namespace updater {
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 {
protected:
void SetUp() override {
@@ -34,6 +54,19 @@
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 updater
diff --git a/chrome/updater/test/integration_tests.h b/chrome/updater/test/integration_tests.h
index 5ae474f..a8bfadb 100644
--- a/chrome/updater/test/integration_tests.h
+++ b/chrome/updater/test/integration_tests.h
@@ -28,15 +28,16 @@
// Expect that the updater is installed on the system and the launchd tasks
// are updated correctly.
void ExpectActive();
-//
-// Make the candidate updater version active.
-void PromoteCandidate();
// 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
// live updater on the machine that ran the test.
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 updater
diff --git a/chrome/updater/test/integration_tests_mac.mm b/chrome/updater/test/integration_tests_mac.mm
index 372dc8a0..60db888e 100644
--- a/chrome/updater/test/integration_tests_mac.mm
+++ b/chrome/updater/test/integration_tests_mac.mm
@@ -13,6 +13,7 @@
#include "chrome/updater/constants.h"
#include "chrome/updater/mac/xpc_service_names.h"
#include "chrome/updater/updater_version.h"
+#include "chrome/updater/util.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace updater {
@@ -106,6 +107,16 @@
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() {
const base::FilePath path = GetExecutablePath();
ASSERT_FALSE(path.empty());
diff --git a/chrome/updater/test/integration_tests_win.cc b/chrome/updater/test/integration_tests_win.cc
index e29b883..96c3b33 100644
--- a/chrome/updater/test/integration_tests_win.cc
+++ b/chrome/updater/test/integration_tests_win.cc
@@ -11,6 +11,7 @@
#include "base/synchronization/waitable_event.h"
#include "base/task/task_traits.h"
#include "base/task/thread_pool.h"
+#include "chrome/updater/constants.h"
#include "chrome/updater/updater_version.h"
#include "chrome/updater/util.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -105,6 +106,23 @@
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() {
int exit_code = -1;
ASSERT_TRUE(Run(base::CommandLine(GetInstallerPath()), &exit_code));