chromium/chrome/browser/ui/tab_sharing/tab_sharing_infobar_delegate_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/ui/tab_sharing/tab_sharing_infobar_delegate.h"

#include <tuple>

#include "base/strings/utf_string_conversions.h"
#include "base/test/scoped_feature_list.h"
#include "chrome/browser/favicon/favicon_utils.h"
#include "chrome/browser/ui/tab_sharing/tab_sharing_ui.h"
#include "chrome/grit/generated_resources.h"
#include "chrome/test/base/browser_with_test_window_test.h"
#include "components/infobars/content/content_infobar_manager.h"
#include "components/infobars/core/infobar.h"
#include "components/url_formatter/elide_url.h"
#include "components/vector_icons/vector_icons.h"
#include "content/public/common/content_features.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/models/image_model.h"
#include "ui/gfx/favicon_size.h"
#include "ui/gfx/image/image_unittest_util.h"
#include "ui/gfx/vector_icon_types.h"

namespace {

FocusTarget;
TabRole;

const std::u16string kSharedTabName =;
const std::u16string kAppName =;
const std::u16string kSinkName =;

const std::u16string kCapturedUrl =;
const std::u16string kCapturingUrl =;

class MockTabSharingUIViews : public TabSharingUI {};

}  // namespace

class TabSharingInfoBarDelegateTest
    : public BrowserWithTestWindowTest,
      public ::testing::WithParamInterface<std::tuple<bool, bool>> {};

// Templatize test on:
// 1. Whether Captured Surface Control is considered "active". That is,
// sendWheel() or setZoomLevel() were called.
// 2. Whether a favicon is expected.
INSTANTIATE_TEST_SUITE_P();

TEST_P(TabSharingInfoBarDelegateTest, StartSharingOnCancel) {}

TEST_P(TabSharingInfoBarDelegateTest, StopSharingOnAccept) {}

// Test that the infobar on the capturing tab has the correct layout:
// "|icon| Sharing this tab to |app| [Switch to captured]"
// If Captured Surface Control is active, the CSC indicator
// should also be visible.
TEST_P(TabSharingInfoBarDelegateTest, InfobarOnCapturingTab) {}

// Test that the infobar on the shared tab has the correct layout:
// "|icon| Sharing this tab to |app| [Switch to capturer]"
TEST_P(TabSharingInfoBarDelegateTest, InfobarOnCapturedTab) {}

// Test that the infobar on another not share tab has the correct layout:
// |icon| Sharing |shared_tab| to |app| [Stop sharing] [Share this tab instead]
TEST_P(TabSharingInfoBarDelegateTest, InfobarOnNotSharedTab) {}

// Test that when dynamic surface switching is not allowed, the infobar only
// has one button (the "Stop" button) on both shared and not shared tabs.
TEST_P(TabSharingInfoBarDelegateTest, InfobarWhenSharingNotAllowed) {}

// Test that if the app preferred self-capture, but the user either chose
// another tab, or chose the current tab but then switched to sharing another,
// then the infobar has the correct layout:
// |icon| Sharing |shared_tab| to |app| [Stop] [STTI] [Qick-nav]
// (Where STTI = share-this-tab-instead, and quick-nav changes the focused tab.)
TEST_P(TabSharingInfoBarDelegateTest,
       InfobarOnCapturingTabIfCapturedAnotherTabButSelfCapturePreferred) {}

// Test that multiple infobars can be created on the same tab.
TEST_P(TabSharingInfoBarDelegateTest, MultipleInfobarsOnSameTab) {}

TEST_P(TabSharingInfoBarDelegateTest, InfobarNotDismissedOnNavigation) {}

// Test that the infobar on another not cast tab has the correct layout:
// "|icon| Casting |tab_being_cast| to |sink| [Stop casting] [Cast this tab
// instead]"
TEST_P(TabSharingInfoBarDelegateTest, InfobarOnNotCastTab) {}

// Test that the infobar on the tab being cast has the correct layout:
// "|icon| Casting this tab to |sink| [Stop casting]"
TEST_P(TabSharingInfoBarDelegateTest, InfobarOnCastTab) {}

// TODO(crbug.com/324468211): Add unit tests for CSC. (After completing the
// CL-chain and ensuring that the button is only shown after the first CSC API
// is invoked.)