chromium/components/web_modal/web_contents_modal_dialog_manager_unittest.cc

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

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/40285824): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include "components/web_modal/web_contents_modal_dialog_manager.h"

#include <map>
#include <memory>

#include "base/memory/ptr_util.h"
#include "base/memory/raw_ptr.h"
#include "build/build_config.h"
#include "components/web_modal/single_web_contents_dialog_manager.h"
#include "components/web_modal/test_web_contents_modal_dialog_manager_delegate.h"
#include "content/public/test/test_renderer_host.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace web_modal {

class MockCloseOnNavigationObserver
    : public WebContentsModalDialogManager::CloseOnNavigationObserver {};

// Tracks persistent state changes of the native WC-modal dialog manager.
class NativeManagerTracker {};

NativeManagerTracker unused_tracker;

class TestNativeWebContentsModalDialogManager
    : public SingleWebContentsDialogManager {};

class WebContentsModalDialogManagerTest
    : public content::RenderViewHostTestHarness {};

// Test that the dialog is shown immediately when the delegate indicates the web
// contents is visible.
TEST_F(WebContentsModalDialogManagerTest, WebContentsVisible) {}

// Test that the dialog is not shown immediately when the delegate indicates the
// web contents is not visible.
TEST_F(WebContentsModalDialogManagerTest, WebContentsNotVisible) {}

// Test that only the first of multiple dialogs is shown.
TEST_F(WebContentsModalDialogManagerTest, ShowDialogs) {}

// Test that the dialog is shown/hidden when the WebContents is shown/hidden.
TEST_F(WebContentsModalDialogManagerTest, VisibilityObservation) {}

// Tests that the dialog shows when switching from occluded to visible.
TEST_F(WebContentsModalDialogManagerTest, OccludedToVisible) {}

// Tests that the dialog is not shown when switching from visible to occluded.
// Regression test for crbug.com/350745485.
TEST_F(WebContentsModalDialogManagerTest, VisibleToOccluded) {}

// Test that the first dialog is always shown, regardless of the order in which
// dialogs are closed.
TEST_F(WebContentsModalDialogManagerTest, CloseDialogs) {}

// Test that CloseAllDialogs does what it says.
TEST_F(WebContentsModalDialogManagerTest, CloseAllDialogs) {}

// Test that dialogs are closed on WebContents navigation.
TEST_F(WebContentsModalDialogManagerTest, CloseOnNavigation) {}

// Test that the CloseOnNavigation observer is not triggered if the dialog is
// closed for another reason.
TEST_F(WebContentsModalDialogManagerTest,
       ObserverNotNotifiedOfNonNavigationClose) {}

}  // namespace web_modal