Birch: Fix timezone for birch unittests
Some birch unittests were failing, because they can depend on the local system timezone. Override the timezone to fix these tests. Bug: b/335334422 Change-Id: I43b121b597dbcb9220e63bfe87bbd1628f755224 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5464419 Commit-Queue: Matthew Mourgos <mmourgos@chromium.org> Reviewed-by: Sammie Quon <sammiequon@chromium.org> Reviewed-by: Steven Bennetts <stevenjb@chromium.org> Cr-Commit-Position: refs/heads/main@{#1289356}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
a7550987fb
commit
196bba7b4b
ash
@ -1,3 +1,4 @@
|
||||
include_rules = [
|
||||
"+chromeos/ash/components/geolocation",
|
||||
"+chromeos/ash/components/settings",
|
||||
]
|
||||
|
@ -9,12 +9,14 @@
|
||||
|
||||
#include "ash/public/cpp/test/test_image_downloader.h"
|
||||
#include "ash/public/cpp/test/test_new_window_delegate.h"
|
||||
#include "ash/system/time/calendar_unittest_utils.h"
|
||||
#include "ash/test/ash_test_base.h"
|
||||
#include "base/files/file_path.h"
|
||||
#include "base/memory/raw_ptr.h"
|
||||
#include "base/test/metrics/histogram_tester.h"
|
||||
#include "base/test/scoped_mock_clock_override.h"
|
||||
#include "base/time/time.h"
|
||||
#include "chromeos/ash/components/settings/scoped_timezone_settings.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "ui/base/models/image_model.h"
|
||||
#include "ui/chromeos/styles/cros_tokens_color_mappings.h"
|
||||
@ -45,7 +47,9 @@ class TestNewWindowDelegateImpl : public TestNewWindowDelegate {
|
||||
|
||||
class BirchItemTest : public testing::Test {
|
||||
public:
|
||||
BirchItemTest() {
|
||||
BirchItemTest()
|
||||
: ash_timezone_(u"America/Los_Angeles"),
|
||||
scoped_libc_timezone_("America/Los_Angeles") {
|
||||
auto new_window_delegate = std::make_unique<TestNewWindowDelegateImpl>();
|
||||
new_window_delegate_ = new_window_delegate.get();
|
||||
new_window_delegate_provider_ =
|
||||
@ -64,6 +68,10 @@ class BirchItemTest : public testing::Test {
|
||||
raw_ptr<TestNewWindowDelegateImpl> new_window_delegate_ = nullptr;
|
||||
// Use an arbitrary but fixed "now" time for tests.
|
||||
base::ScopedMockClockOverride mock_clock_override_;
|
||||
|
||||
// Ensure consistent timezones for testing.
|
||||
ash::system::ScopedTimezoneSettings ash_timezone_;
|
||||
calendar_test_utils::ScopedLibcTimeZone scoped_libc_timezone_;
|
||||
};
|
||||
|
||||
TEST_F(BirchItemTest, RecordActionMetrics_Basics) {
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "ash/shelf/shelf.h"
|
||||
#include "ash/shell.h"
|
||||
#include "ash/style/switch.h"
|
||||
#include "ash/system/time/calendar_unittest_utils.h"
|
||||
#include "ash/test/ash_test_base.h"
|
||||
#include "ash/wallpaper/views/wallpaper_widget_controller.h"
|
||||
#include "ash/wm/overview/birch/birch_bar_context_menu_model.h"
|
||||
@ -365,6 +366,10 @@ TEST_F(BirchBarTest, DoNotShowBirchBarForSecondaryUser) {
|
||||
}
|
||||
|
||||
TEST_F(BirchBarTest, RecordsHistogramWhenChipsShown) {
|
||||
// Ensure a consistent timezone for this test.
|
||||
calendar_test_utils::ScopedLibcTimeZone scoped_timezone(
|
||||
"America/Los_Angeles");
|
||||
|
||||
base::HistogramTester histograms;
|
||||
|
||||
// Add an ongoing calendar event at the current time. This will create a
|
||||
|
Reference in New Issue
Block a user