1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
ash / wallpaper / wallpaper_utils / wallpaper_resolution_unittest.cc [blame]
// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/wallpaper/wallpaper_utils/wallpaper_resolution.h"
#include "ash/public/cpp/wallpaper/wallpaper_types.h"
#include "ash/test/ash_test_base.h"
#include "base/strings/stringprintf.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace ash {
using GetMaxDisplaySizeTest = AshTestBase;
TEST_F(GetMaxDisplaySizeTest, DeviceScaleFactorIgnored) {
// Device scale factor shouldn't affect the native size.
UpdateDisplay("1000x300*2");
EXPECT_EQ("1000x300", GetMaxDisplaySizeInNative().ToString());
}
TEST_F(GetMaxDisplaySizeTest, RotatedDisplayReturnsRotatedSize) {
UpdateDisplay("1000x300*2/r");
EXPECT_EQ("300x1000", GetMaxDisplaySizeInNative().ToString());
}
TEST_F(GetMaxDisplaySizeTest, UiScalingIgnored) {
UpdateDisplay("1000x300*2@1.5");
EXPECT_EQ("1000x300", GetMaxDisplaySizeInNative().ToString());
}
TEST_F(GetMaxDisplaySizeTest, FirstDisplayLarger) {
UpdateDisplay("400x300,200x100");
EXPECT_EQ("400x300", GetMaxDisplaySizeInNative().ToString());
}
TEST_F(GetMaxDisplaySizeTest, SecondDisplayLarger) {
UpdateDisplay("400x300,500x600");
EXPECT_EQ("500x600", GetMaxDisplaySizeInNative().ToString());
}
TEST_F(GetMaxDisplaySizeTest, MaximumDimensionDifferentDisplays) {
UpdateDisplay("400x300,100x500");
EXPECT_EQ("400x500", GetMaxDisplaySizeInNative().ToString());
}
using GetAppropriateResolutionTest = AshTestBase;
TEST_F(GetAppropriateResolutionTest, SmallResolutionIfBothDimensionsSmall) {
UpdateDisplay(base::StringPrintf("%ix%i", kSmallWallpaperMaxWidth,
kSmallWallpaperMaxHeight));
EXPECT_EQ(WallpaperResolution::kSmall, GetAppropriateResolution());
}
TEST_F(GetAppropriateResolutionTest, LargeResolutionIfEitherLarge) {
const std::vector<gfx::Size> sizes = {
{kSmallWallpaperMaxWidth + 1, kSmallWallpaperMaxHeight},
{kSmallWallpaperMaxWidth, kSmallWallpaperMaxHeight + 1}};
for (const auto& size : sizes) {
UpdateDisplay(base::StringPrintf("%ix%i", size.width(), size.height()));
EXPECT_EQ(WallpaperResolution::kLarge, GetAppropriateResolution());
}
}
} // namespace ash