summaryrefslogtreecommitdiff
path: root/chromium/ui/native_theme/caption_style_win_unittest.cc
blob: 32595becbe30291f7cf664fb0cb1599325961163 (plain)
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
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ui/native_theme/caption_style.h"

#include "base/test/scoped_feature_list.h"
#include "base/win/scoped_com_initializer.h"
#include "base/win/windows_version.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/ui_base_features.h"

namespace ui {

// Test to ensure closed caption styling from system settings can be obtained
// (we obtain a CaptionStyle) on Windows 10.
TEST(CaptionStyleWinTest, TestWinCaptionStyle) {
  base::test::ScopedFeatureList scoped_feature_list;
  scoped_feature_list.InitAndEnableFeature(features::kSystemCaptionStyle);

  if (base::win::GetVersion() >= base::win::Version::WIN10) {
    base::win::ScopedCOMInitializer com_initializer;
    ASSERT_TRUE(com_initializer.Succeeded());

    absl::optional<ui::CaptionStyle> caption_style =
        ui::CaptionStyle::FromSystemSettings();
    // On Windows out of the box, all caption style properties are set to
    // Default. In which case, each of these should be empty.
    ASSERT_TRUE(caption_style.has_value());
    EXPECT_TRUE(caption_style->background_color.empty());
    EXPECT_TRUE(caption_style->font_family.empty());
    EXPECT_TRUE(caption_style->font_variant.empty());
    EXPECT_TRUE(caption_style->text_color.empty());
    EXPECT_TRUE(caption_style->text_shadow.empty());
    EXPECT_TRUE(caption_style->text_size.empty());
    EXPECT_TRUE(caption_style->window_color.empty());
  }
}

}  // namespace ui