#include "chrome/browser/net/net_error_tab_helper.h"
#include <memory>
#include "base/memory/raw_ptr.h"
#include "chrome/test/base/chrome_render_view_host_test_harness.h"
#include "components/error_page/common/net_error_info.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/test/mock_navigation_handle.h"
#include "content/public/test/navigation_simulator.h"
#include "content/public/test/test_renderer_host.h"
#include "net/base/net_errors.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/page_transition_types.h"
#include "url/gurl.h"
#undef NO_ERROR
NetErrorTabHelper;
DnsProbeStatus;
class TestNetErrorTabHelper : public NetErrorTabHelper { … };
class NetErrorTabHelperTest : public ChromeRenderViewHostTestHarness { … };
TEST_F(NetErrorTabHelperTest, Null) { … }
TEST_F(NetErrorTabHelperTest, MainFrameNonDnsError) { … }
TEST_F(NetErrorTabHelperTest, NonMainFrameDnsError) { … }
TEST_F(NetErrorTabHelperTest, ProbeResponse) { … }
TEST_F(NetErrorTabHelperTest, ProbeResponseAfterNewStart) { … }
TEST_F(NetErrorTabHelperTest, ProbeResponseAfterNewCommit) { … }
TEST_F(NetErrorTabHelperTest, MultipleDnsErrorsWithProbesWithoutErrorPages) { … }
TEST_F(NetErrorTabHelperTest, MultipleDnsErrorsWithProbesAndErrorPages) { … }
TEST_F(NetErrorTabHelperTest, CoalesceFailures) { … }
TEST_F(NetErrorTabHelperTest, SanitizeDiagnosticsUrl) { … }
TEST_F(NetErrorTabHelperTest, NoDiagnosticsForNonHttpSchemes) { … }
#if BUILDFLAG(ENABLE_OFFLINE_PAGES)
TEST_F(NetErrorTabHelperTest, DownloadPageLater) {
GURL url("http://somewhere:123/");
LoadURL(url, false );
tab_helper()->DownloadPageLater();
EXPECT_EQ(url, tab_helper()->download_page_later_url());
EXPECT_EQ(1, tab_helper()->times_download_page_later_invoked());
}
TEST_F(NetErrorTabHelperTest, NoDownloadPageLaterOnNonErrorPage) {
GURL url("http://somewhere:123/");
LoadURL(url, true );
tab_helper()->DownloadPageLater();
EXPECT_EQ(0, tab_helper()->times_download_page_later_invoked());
}
TEST_F(NetErrorTabHelperTest, NoDownloadPageLaterForNonHttpSchemes1) {
NoDownloadPageLaterForNonHttpSchemes("file:///blah/blah", false);
}
TEST_F(NetErrorTabHelperTest, NoDownloadPageLaterForNonHttpSchemes2) {
NoDownloadPageLaterForNonHttpSchemes("chrome://blah/", false);
}
TEST_F(NetErrorTabHelperTest, NoDownloadPageLaterForNonHttpSchemes3) {
NoDownloadPageLaterForNonHttpSchemes("about:blank", true);
}
#endif