wallpaper: deflake daily refresh test

Previously, the test tried to set the value of dark mode pref, which
could eventually call `OnColorModeChanged`. This created a flaky
behavior because the test also made this same call explicitly. This fix
only attempts to switch the color mode once to prevent this race
condition to happen.

BUG=crbug.com/1362424
TEST=ash_unittests --gtest_filter="WallpaperControllerTest.*"

Cq-Include-Trybots: luci.chrome.try:linux-chromeos-chrome
Change-Id: I3ee3c3651111935c3aef6d23df8c759324bcbd63
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3905486
Reviewed-by: Xiaohui Chen <xiaohuic@chromium.org>
Commit-Queue: Jason Thai <jasontt@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1048788}
diff --git a/ash/wallpaper/wallpaper_controller_unittest.cc b/ash/wallpaper/wallpaper_controller_unittest.cc
index 7235038..5ea42ba 100644
--- a/ash/wallpaper/wallpaper_controller_unittest.cc
+++ b/ash/wallpaper/wallpaper_controller_unittest.cc
@@ -24,6 +24,7 @@
 #include "ash/session/session_controller_impl.h"
 #include "ash/session/test_session_controller_client.h"
 #include "ash/shell.h"
+#include "ash/style/dark_light_mode_controller_impl.h"
 #include "ash/test/ash_test_base.h"
 #include "ash/wallpaper/test_wallpaper_controller_client.h"
 #include "ash/wallpaper/wallpaper_pref_manager.h"
@@ -4047,12 +4048,9 @@
 
   // Fast forward by one hour and attempt a system's color mode change.
   task_environment()->FastForwardBy(base::Hours(1));
-  Shell::Get()->session_controller()->GetActivePrefService()->SetBoolean(
-      prefs::kDarkModeEnabled, true);
-  controller_->OnColorModeChanged(true);
+  Shell::Get()->dark_light_mode_controller()->ToggleColorMode();
   RunAllTasksUntilIdle();
-  // TODO(crbug.com/1362424): Figure out why this is flaky.
-  // EXPECT_EQ(2, GetWallpaperCount());
+  EXPECT_EQ(2, GetWallpaperCount());
   // Expect the refresh timer doesn't reset.
   EXPECT_EQ(
       run_time,