update_engine: UM: UpdateCheckAllowed now considers interactive update requests.

This is necessary so we can delegate handling of all update checks to
the UpdateManager, allowing us to share logic between the two cases and
eliminate multiple entry point to UpdateAttempter::Update() and handling
of interference between these two processes. Instead, these are all
handled naturally by the UpdateManager.

BUG=chromium:394389
TEST=Unit tests.

Change-Id: I32a1ab917e5aeb5c2da1953d8b0ffa8c9d8d62f9
Reviewed-on: https://chromium-review.googlesource.com/209100
Reviewed-by: Gilad Arnold <garnold@chromium.org>
Tested-by: Gilad Arnold <garnold@chromium.org>
Commit-Queue: Gilad Arnold <garnold@chromium.org>
diff --git a/update_manager/chromeos_policy_unittest.cc b/update_manager/chromeos_policy_unittest.cc
index ef609c1..f79c4fc 100644
--- a/update_manager/chromeos_policy_unittest.cc
+++ b/update_manager/chromeos_policy_unittest.cc
@@ -50,6 +50,8 @@
         reset(new unsigned int(0));  // NOLINT(readability/casting)
     fake_state_.updater_provider()->var_server_dictated_poll_interval()->
         reset(new unsigned int(0));  // NOLINT(readability/casting)
+    fake_state_.updater_provider()->var_interactive_update_requested()->
+        reset(new bool(false));  // NOLINT(readability/casting)
 
     fake_state_.random_provider()->var_seed()->reset(
         new uint64_t(4));  // chosen by fair dice roll.
@@ -290,6 +292,7 @@
   ExpectPolicyStatus(EvalStatus::kSucceeded,
                      &Policy::UpdateCheckAllowed, &result);
   EXPECT_TRUE(result.updates_enabled);
+  EXPECT_FALSE(result.is_interactive);
 }
 
 TEST_F(UmChromeOSPolicyTest, UpdateCheckAllowedWaitsForOOBE) {
@@ -326,6 +329,7 @@
   ExpectPolicyStatus(EvalStatus::kSucceeded,
                      &Policy::UpdateCheckAllowed, &result);
   EXPECT_TRUE(result.updates_enabled);
+  EXPECT_FALSE(result.is_interactive);
 }
 
 TEST_F(UmChromeOSPolicyTest, UpdateCheckAllowedWithAttributes) {
@@ -344,20 +348,20 @@
                      &Policy::UpdateCheckAllowed, &result);
   EXPECT_TRUE(result.updates_enabled);
   EXPECT_EQ("foo-channel", result.target_channel);
+  EXPECT_FALSE(result.is_interactive);
 }
 
 TEST_F(UmChromeOSPolicyTest,
        UpdateCheckAllowedUpdatesDisabledForUnofficialBuilds) {
-  // UpdateCheckAllowed should return false (kSucceeded) if this is an
-  // unofficial build; we don't want periodic update checks on developer images.
+  // UpdateCheckAllowed should return kAskMeAgainLater if this is an unofficial
+  // build; we don't want periodic update checks on developer images.
 
   fake_state_.system_provider()->var_is_official_build()->reset(
       new bool(false));
 
   UpdateCheckParams result;
-  ExpectPolicyStatus(EvalStatus::kSucceeded,
+  ExpectPolicyStatus(EvalStatus::kAskMeAgainLater,
                      &Policy::UpdateCheckAllowed, &result);
-  EXPECT_FALSE(result.updates_enabled);
 }
 
 TEST_F(UmChromeOSPolicyTest,
@@ -387,6 +391,21 @@
                      &Policy::UpdateCheckAllowed, &result);
 }
 
+TEST_F(UmChromeOSPolicyTest, UpdateCheckAllowedInteractiveUpdateRequested) {
+  // UpdateCheckAllowed should return true because an interactive update request
+  // was signaled.
+
+  SetUpdateCheckAllowed(true);
+  fake_state_.updater_provider()->var_interactive_update_requested()->reset(
+      new bool(true));
+
+  UpdateCheckParams result;
+  ExpectPolicyStatus(EvalStatus::kSucceeded,
+                     &Policy::UpdateCheckAllowed, &result);
+  EXPECT_TRUE(result.updates_enabled);
+  EXPECT_TRUE(result.is_interactive);
+}
+
 TEST_F(UmChromeOSPolicyTest, UpdateCanStartFailsCheckAllowedError) {
   // The UpdateCanStart policy fails, not being able to query
   // UpdateCheckAllowed.