chromium/chrome/browser/background_sync/periodic_background_sync_permission_context_unittest.cc

// Copyright 2019 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/background_sync/periodic_background_sync_permission_context.h"

#include <string>

#include "base/test/scoped_feature_list.h"
#include "build/build_config.h"
#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
#include "chrome/test/base/chrome_render_view_host_test_harness.h"
#include "chrome/test/base/testing_profile.h"
#include "components/content_settings/core/browser/host_content_settings_map.h"
#include "components/content_settings/core/common/content_settings.h"
#include "components/content_settings/core/common/content_settings_types.h"
#include "components/permissions/permission_util.h"
#include "content/public/browser/web_contents.h"
#include "content/public/test/web_contents_tester.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace {

class TestPeriodicBackgroundSyncPermissionContext
    : public PeriodicBackgroundSyncPermissionContext {};

class PeriodicBackgroundSyncPermissionContextTest
    : public ChromeRenderViewHostTestHarness {};

TEST_F(PeriodicBackgroundSyncPermissionContextTest, DenyWhenFeatureDisabled) {}

TEST_F(PeriodicBackgroundSyncPermissionContextTest, DenyForInsecureOrigin) {}

TEST_F(PeriodicBackgroundSyncPermissionContextTest, AllowWithFrame) {}

TEST_F(PeriodicBackgroundSyncPermissionContextTest, AllowWithoutFrame) {}

TEST_F(PeriodicBackgroundSyncPermissionContextTest, DesktopPwa) {}

#if BUILDFLAG(IS_ANDROID)
TEST_F(PeriodicBackgroundSyncPermissionContextTest, Twa) {
  GURL url("https://example.com");

  // No TWA or PWA installed.
  EXPECT_EQ(GetPermissionStatus(url), CONTENT_SETTING_BLOCK);

  InstallTwa(url);
  EXPECT_EQ(GetPermissionStatus(url), CONTENT_SETTING_ALLOW);
}
#endif

TEST_F(PeriodicBackgroundSyncPermissionContextTest, DefaultSearchEngine) {}

class PeriodicBackgroundSyncPermissionContextWithPermissionTest
    : public PeriodicBackgroundSyncPermissionContextTest {};

TEST_F(PeriodicBackgroundSyncPermissionContextWithPermissionTest,
       DefaultSearchEngine) {}

}  // namespace