chromium/chrome/browser/ui/toolbar/cast/cast_contextual_menu_unittest.cc

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

#include <memory>
#include <utility>

#include "base/functional/bind.h"
#include "base/memory/raw_ptr.h"
#include "build/branding_buildflags.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/extensions/extension_action_test_util.h"
#include "chrome/browser/extensions/load_error_reporter.h"
#include "chrome/browser/media/router/chrome_media_router_factory.h"
#include "chrome/browser/signin/identity_test_environment_profile_adaptor.h"
#include "chrome/browser/ui/media_router/media_router_ui_service.h"
#include "chrome/browser/ui/media_router/media_router_ui_service_factory.h"
#include "chrome/browser/ui/toolbar/cast/cast_toolbar_button_controller.h"
#include "chrome/browser/ui/toolbar/cast/cast_contextual_menu.h"
#include "chrome/browser/ui/toolbar/cast/mock_cast_toolbar_button_controller.h"
#include "chrome/grit/branded_strings.h"
#include "chrome/grit/generated_resources.h"
#include "chrome/test/base/browser_with_test_window_test.h"
#include "components/media_router/browser/test/mock_media_router.h"
#include "components/media_router/common/pref_names.h"
#include "components/signin/public/identity_manager/identity_manager.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/l10n/l10n_util.h"

NiceMock;

namespace {

// These constants are used to inject the state of the Cast toolbar icon
// that would be inferred in the production code.
constexpr bool kShownByPolicy =;
constexpr bool kShownByUser =;

bool HasCommandId(ui::MenuModel* menu_model, int command_id) {}

std::unique_ptr<KeyedService> BuildUIService(content::BrowserContext* context) {}

class MockCastContextualMenuObserver
    : public CastContextualMenu::Observer {};

}  // namespace

class CastContextualMenuUnitTest : public BrowserWithTestWindowTest {};

// Tests the basic state of the contextual menu.
TEST_F(CastContextualMenuUnitTest, Basic) {}

#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
// "Report an issue" should be present for normal profiles as well as for
// incognito.
TEST_F(CastContextualMenuUnitTest, EnableAndDisableReportIssue) {
  CastContextualMenu menu(browser(), kShownByPolicy, &observer_);
  EXPECT_TRUE(
      menu.CreateMenuModel()
          ->GetIndexOfCommandId(IDC_MEDIA_TOOLBAR_CONTEXT_REPORT_CAST_ISSUE)
          .has_value());

  std::unique_ptr<BrowserWindow> window(CreateBrowserWindow());
  std::unique_ptr<Browser> incognito_browser(
      CreateBrowser(profile()->GetPrimaryOTRProfile(/*create_if_needed=*/true),
                    Browser::TYPE_NORMAL, false, window.get()));

  CastContextualMenu incognito_menu(incognito_browser.get(),
                                           kShownByPolicy, &observer_);
  EXPECT_TRUE(
      incognito_menu.CreateMenuModel()
          ->GetIndexOfCommandId(IDC_MEDIA_TOOLBAR_CONTEXT_REPORT_CAST_ISSUE)
          .has_value());
}
#endif

TEST_F(CastContextualMenuUnitTest, ToggleMediaRemotingItem) {}

TEST_F(CastContextualMenuUnitTest, ToggleAlwaysShowIconItem) {}

TEST_F(CastContextualMenuUnitTest, ActionShownByPolicy) {}

TEST_F(CastContextualMenuUnitTest, NotifyActionController) {}