1 // Copyright (c) 2011 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.
5 #include "content/public/test/content_browser_test.h"
7 #include "base/command_line.h"
8 #include "base/location.h"
9 #include "base/single_thread_task_runner.h"
10 #include "base/strings/utf_string_conversions.h"
11 #include "base/thread_task_runner_handle.h"
12 #include "content/public/common/content_switches.h"
13 #include "content/public/test/browser_test_utils.h"
14 #include "content/public/test/content_browser_test_utils.h"
15 #include "content/public/test/test_utils.h"
16 #include "content/shell/browser/shell.h"
17 #include "testing/gtest/include/gtest/gtest.h"
21 IN_PROC_BROWSER_TEST_F(ContentBrowserTest
, MANUAL_ShouldntRun
) {
22 // Ensures that tests with MANUAL_ prefix don't run automatically.
26 class ContentBrowserTestSanityTest
: public ContentBrowserTest
{
28 void SetUpCommandLine(base::CommandLine
* command_line
) override
{
29 const testing::TestInfo
* const test_info
=
30 testing::UnitTest::GetInstance()->current_test_info();
31 if (std::string(test_info
->name()) == "SingleProcess")
32 command_line
->AppendSwitch(switches::kSingleProcess
);
36 GURL url
= GetTestUrl(".", "simple_page.html");
38 base::string16
expected_title(base::ASCIIToUTF16("OK"));
39 TitleWatcher
title_watcher(shell()->web_contents(), expected_title
);
40 NavigateToURL(shell(), url
);
41 base::string16 title
= title_watcher
.WaitAndGetTitle();
42 EXPECT_EQ(expected_title
, title
);
46 IN_PROC_BROWSER_TEST_F(ContentBrowserTestSanityTest
, Basic
) {
50 IN_PROC_BROWSER_TEST_F(ContentBrowserTestSanityTest
, SingleProcess
) {
56 void CallbackChecker(bool* non_nested_task_ran
) {
57 *non_nested_task_ran
= true;
62 IN_PROC_BROWSER_TEST_F(ContentBrowserTestSanityTest
, NonNestableTask
) {
63 bool non_nested_task_ran
= false;
64 base::ThreadTaskRunnerHandle::Get()->PostNonNestableTask(
65 FROM_HERE
, base::Bind(&CallbackChecker
, &non_nested_task_ran
));
66 content::RunAllPendingInMessageLoop();
67 ASSERT_TRUE(non_nested_task_ran
);
70 } // namespace content