popup_blocker_browsertest.cc revision 21d179b334e59e9a3bfcaed4c4430bef1bc5759d
1// Copyright (c) 2010 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "base/command_line.h"
6#include "base/file_path.h"
7#include "base/file_util.h"
8#include "base/path_service.h"
9#include "base/message_loop.h"
10#include "chrome/browser/browser_list.h"
11#include "chrome/browser/browser_window.h"
12#include "chrome/browser/profiles/profile.h"
13#include "chrome/browser/tab_contents/tab_contents.h"
14#include "chrome/browser/ui/browser.h"
15#include "chrome/common/chrome_paths.h"
16#include "chrome/common/chrome_switches.h"
17#include "chrome/test/in_process_browser_test.h"
18#include "chrome/test/ui_test_utils.h"
19#include "testing/gtest/include/gtest/gtest.h"
20
21namespace {
22
23static const FilePath::CharType* kTestDir = FILE_PATH_LITERAL("popup_blocker");
24
25typedef InProcessBrowserTest PopupBlockerBrowserTest;
26
27IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest, PopupBlockedPostBlank) {
28  FilePath file_name(FILE_PATH_LITERAL("popup-blocked-to-post-blank.html"));
29  FilePath test_dir(kTestDir);
30  GURL url(ui_test_utils::GetTestUrl(test_dir, file_name));
31  ui_test_utils::NavigateToURL(browser(), url);
32
33  // If the popup blocker blocked the blank post, there should be only one
34  // tab in only one browser window and the URL of current tab must be equal
35  // to the original URL.
36  EXPECT_EQ(1u, BrowserList::GetBrowserCount(browser()->profile()));
37  EXPECT_EQ(1, browser()->tab_count());
38  TabContents* cur_tab = browser()->GetSelectedTabContents();
39  ASSERT_TRUE(cur_tab);
40  EXPECT_EQ(url, cur_tab->GetURL());
41}
42
43}  // namespace
44
45