// Copyright 2021 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CONTENT_PUBLIC_TEST_MOCK_WEB_CONTENTS_OBSERVER_H_ #define CONTENT_PUBLIC_TEST_MOCK_WEB_CONTENTS_OBSERVER_H_ #include "content/public/browser/web_contents_observer.h" #include "testing/gmock/include/gmock/gmock.h" #include "ui/accessibility/ax_updates_and_events.h" namespace content { // A mock WebContentsObserver with which tests can set expectations for how // observer methods are called in response to actions taken in the test. // // For example: // GURL url = ... // testing::NiceMock<MockWebContentsObserver> observer(web_contents()); // EXPECT_CALL(observer, // DidStartNavigation( // testing::Truly([&](NavigationHandle* navigation_handle) { // return navigation_handle->GetURL() == url; // }))); // EXPECT_TRUE(NavigateToURL(shell(), url)); // class MockWebContentsObserver : public WebContentsObserver { … }; } // namespace content #endif // CONTENT_PUBLIC_TEST_MOCK_WEB_CONTENTS_OBSERVER_H_