#include "base/test/scoped_feature_list.h"
#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
#include "chrome/browser/permissions/system/system_permission_settings.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_element_identifiers.h"
#include "chrome/browser/ui/views/page_info/page_info_main_view.h"
#include "chrome/browser/ui/views/page_info/permission_toggle_row_view.h"
#include "chrome/browser/ui/views/permissions/chip/permission_chip_theme.h"
#include "chrome/browser/ui/views/permissions/chip/permission_chip_view.h"
#include "chrome/browser/ui/views/permissions/chip/permission_dashboard_view.h"
#include "chrome/browser/ui/views/permissions/permission_prompt_bubble_base_view.h"
#include "chrome/test/interaction/interactive_browser_test.h"
#include "components/content_settings/core/common/content_settings_types.h"
#include "components/content_settings/core/common/features.h"
#include "components/strings/grit/components_strings.h"
#include "content/public/test/browser_test.h"
#include "net/dns/mock_host_resolver.h"
namespace {
DEFINE_LOCAL_ELEMENT_IDENTIFIER_VALUE(…);
const char kFirstPermissionRow[] = …;
const char kSecondPermissionRow[] = …;
}
class DashboardKombuchaInteractiveUITest : public InteractiveBrowserTest { … };
IN_PROC_BROWSER_TEST_F(DashboardKombuchaInteractiveUITest,
PermissionChipClickTest) { … }
IN_PROC_BROWSER_TEST_F(DashboardKombuchaInteractiveUITest, CameraUsingTest) { … }
IN_PROC_BROWSER_TEST_F(DashboardKombuchaInteractiveUITest,
CameraUsingTestWithSystemBlock) { … }
IN_PROC_BROWSER_TEST_F(DashboardKombuchaInteractiveUITest,
MicrophoneUsingTest) { … }
IN_PROC_BROWSER_TEST_F(DashboardKombuchaInteractiveUITest,
MicrophoneUsingTestWithSystemBlock) { … }
#if BUILDFLAG(IS_CHROMEOS)
IN_PROC_BROWSER_TEST_F(DashboardKombuchaInteractiveUITest, LocationUsingTest) {
SetPermission(ContentSettingsType::GEOLOCATION, CONTENT_SETTING_ALLOW);
system_permission_settings::ScopedSettingsForTesting scoped_system_permission(
ContentSettingsType::GEOLOCATION, false);
RunTestSequence(
InstrumentTab(kWebContentsElementId),
NavigateWebContents(kWebContentsElementId, GetURL()),
EnsureNotPresent(PermissionDashboardView::kDashboardElementId),
ExecuteJs(kWebContentsElementId, "requestLocation"),
PressButton(kLocationIconElementId),
WaitForShow(PageInfoMainView::kPermissionsElementId),
CheckViewProperty(PageInfoMainView::kMainLayoutElementId,
&PageInfoMainView::GetVisiblePermissionsCountForTesting,
1),
NameChildView(PageInfoMainView::kPermissionsElementId,
kFirstPermissionRow, 0u),
CheckViewProperty(
kFirstPermissionRow, &PermissionToggleRowView::GetRowTitleForTesting,
l10n_util::GetStringUTF16(IDS_SITE_SETTINGS_TYPE_LOCATION)),
EnsureNotPresent(
PermissionToggleRowView::kPermissionDisabledAtSystemLevelElementId));
}
IN_PROC_BROWSER_TEST_F(DashboardKombuchaInteractiveUITest,
LocationUsingTestWithSystemBlock) {
SetPermission(ContentSettingsType::GEOLOCATION, CONTENT_SETTING_ALLOW);
system_permission_settings::ScopedSettingsForTesting scoped_system_permission(
ContentSettingsType::GEOLOCATION, true);
RunTestSequence(
InstrumentTab(kWebContentsElementId),
NavigateWebContents(kWebContentsElementId, GetURL()),
EnsureNotPresent(PermissionDashboardView::kDashboardElementId),
ExecuteJs(kWebContentsElementId, "requestLocation"),
PressButton(kLocationIconElementId),
WaitForShow(PageInfoMainView::kPermissionsElementId),
CheckViewProperty(PageInfoMainView::kMainLayoutElementId,
&PageInfoMainView::GetVisiblePermissionsCountForTesting,
1),
NameChildView(PageInfoMainView::kPermissionsElementId,
kFirstPermissionRow, 0u),
CheckViewProperty(
kFirstPermissionRow, &PermissionToggleRowView::GetRowTitleForTesting,
l10n_util::GetStringUTF16(IDS_SITE_SETTINGS_TYPE_LOCATION)),
WaitForShow(
PermissionToggleRowView::kPermissionDisabledAtSystemLevelElementId));
}
#endif
IN_PROC_BROWSER_TEST_F(DashboardKombuchaInteractiveUITest,
CameraAndMicrophoneUsingTest) { … }
IN_PROC_BROWSER_TEST_F(DashboardKombuchaInteractiveUITest,
CameraPermissionBlockedInUseTest) { … }
IN_PROC_BROWSER_TEST_F(DashboardKombuchaInteractiveUITest,
MicrophonePermissionBlockedInUseTest) { … }
IN_PROC_BROWSER_TEST_F(DashboardKombuchaInteractiveUITest,
CameraAndMicrophonePermissionsBlockedInUseTest) { … }
IN_PROC_BROWSER_TEST_F(DashboardKombuchaInteractiveUITest,
CameraAllowStartStopTest) { … }
IN_PROC_BROWSER_TEST_F(DashboardKombuchaInteractiveUITest,
CameraBlockStartStopTest) { … }
IN_PROC_BROWSER_TEST_F(DashboardKombuchaInteractiveUITest,
MicrophoneAllowStartStopTest) { … }
IN_PROC_BROWSER_TEST_F(DashboardKombuchaInteractiveUITest,
MicBlockStartStopTest) { … }
IN_PROC_BROWSER_TEST_F(DashboardKombuchaInteractiveUITest,
SuppressPageInfoReopen) { … }