Commit d46ccaf5 authored by Charles Harrison's avatar Charles Harrison Committed by Commit Bot

[tab_under] Add console logging unit test

Now that RenderFrameHostTesters keep track of these messages, it makes
writing unit tests pretty easy.

Bug: 661629
Change-Id: I3ddd13d7d9a83a90dba70dc6807073bf3d4b2b46
Reviewed-on: https://chromium-review.googlesource.com/749319Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Commit-Queue: Charlie Harrison <csharrison@chromium.org>
Cr-Commit-Position: refs/heads/master@{#513231}
parent 818bcea9
...@@ -567,3 +567,21 @@ TEST_F(BlockTabUnderTest, LogsRappor) { ...@@ -567,3 +567,21 @@ TEST_F(BlockTabUnderTest, LogsRappor) {
EXPECT_EQ(first_url.host(), sample); EXPECT_EQ(first_url.host(), sample);
EXPECT_EQ(rappor::UMA_RAPPOR_TYPE, type); EXPECT_EQ(rappor::UMA_RAPPOR_TYPE, type);
} }
TEST_F(BlockTabUnderTest, LogsToConsole) {
EXPECT_TRUE(NavigateAndCommitWithoutGesture(GURL("https://first.test/")));
SimulatePopup();
const GURL blocked_url("https://example.test/");
const auto& messages =
content::RenderFrameHostTester::For(main_rfh())->GetConsoleMessages();
EXPECT_EQ(0u, messages.size());
EXPECT_FALSE(NavigateAndCommitWithoutGesture(blocked_url));
ExpectUIShown(true);
EXPECT_EQ(1u, messages.size());
std::string expected_message = base::StringPrintf(kBlockTabUnderFormatMessage,
blocked_url.spec().c_str());
EXPECT_EQ(expected_message, messages.front());
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment