blob: 1375beea0b27a14e5d19a17337f27ca5a4bd4edc [file] [log] [blame]
Takumi Fujimotoa2e9ecf2024-06-23 13:14:521// Copyright 2024 The Chromium Authors
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "components/page_info/page_info_ui.h"
6
7#include "build/buildflag.h"
8#include "components/page_info/page_info_ui_delegate.h"
9#include "components/strings/grit/components_strings.h"
10#include "testing/gmock/include/gmock/gmock.h"
11#include "testing/gtest/include/gtest/gtest.h"
12#include "ui/base/l10n/l10n_util.h"
13
14namespace {
15
16class MockPageInfoUiDelegate : public PageInfoUiDelegate {
17 public:
18#if !BUILDFLAG(IS_ANDROID)
19 MOCK_METHOD(bool, IsBlockAutoPlayEnabled, (), (override));
20 MOCK_METHOD(bool, IsMultipleTabsOpen, (), (override));
21 MOCK_METHOD(void, OpenSiteSettingsFileSystem, (), (override));
22#endif
Takumi Fujimotoa2e9ecf2024-06-23 13:14:5223 MOCK_METHOD(content::PermissionResult,
24 GetPermissionResult,
25 (blink::PermissionType permission),
26 (override));
27 MOCK_METHOD(std::optional<content::PermissionResult>,
28 GetEmbargoResult,
29 (ContentSettingsType type),
30 (override));
Olesia Marukhno52e84342024-12-12 10:46:1031 MOCK_METHOD(void,
32 GetMerchantTrustInfo,
33 (page_info::MerchantDataCallback callback),
34 (override));
Takumi Fujimotoa2e9ecf2024-06-23 13:14:5235};
36
37} // namespace
38
39TEST(PageInfoUITest, PermissionStateToUIString) {
40 MockPageInfoUiDelegate delegate;
41 PageInfo::PermissionInfo permission_info;
42 permission_info.setting = CONTENT_SETTING_ASK;
43
44 permission_info.type = ContentSettingsType::KEYBOARD_LOCK;
45 EXPECT_EQ(
46 l10n_util::GetStringUTF16(IDS_PAGE_INFO_STATE_TEXT_KEYBOARD_LOCK_ASK),
47 PageInfoUI::PermissionStateToUIString(&delegate, permission_info));
48
49 permission_info.type = ContentSettingsType::POINTER_LOCK;
50 EXPECT_EQ(
51 l10n_util::GetStringUTF16(IDS_PAGE_INFO_STATE_TEXT_POINTER_LOCK_ASK),
52 PageInfoUI::PermissionStateToUIString(&delegate, permission_info));
53}