Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Side by Side Diff: content/test/content_browser_test.cc

Issue 8036044: Add (not yet working) content_browsertests target. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/test/content_browser_test.h ('k') | content/test/content_test_launcher.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
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.
4
5 #include "content/test/content_browser_test.h"
6
7 #include "base/debug/stack_trace.h"
8 #include "base/mac/scoped_nsautorelease_pool.h"
9 #include "base/message_loop.h"
10 #include "content/test/test_content_client.h"
11
12 ContentBrowserTest::ContentBrowserTest() {
13 }
14
15 ContentBrowserTest::~ContentBrowserTest() {
16 }
17
18 void ContentBrowserTest::SetUp() {
19 DCHECK(!content::GetContentClient());
20 content_client_.reset(new TestContentClient);
21 content::SetContentClient(content_client_.get());
22
23 content_browser_client_.reset(new content::MockContentBrowserClient());
24 content_client_->set_browser(content_browser_client_.get());
25
26 BrowserTestBase::SetUp();
27 }
28
29 void ContentBrowserTest::TearDown() {
30 BrowserTestBase::TearDown();
31
32 DCHECK_EQ(content_client_.get(), content::GetContentClient());
33 content::SetContentClient(NULL);
34 content_client_.reset();
35
36 content_browser_client_.reset();
37 }
38
39 #if defined(OS_POSIX)
40 // On SIGTERM (sent by the runner on timeouts), dump a stack trace (to make
41 // debugging easier) and also exit with a known error code (so that the test
42 // framework considers this a failure -- http://crbug.com/57578).
43 static void DumpStackTraceSignalHandler(int signal) {
44 base::debug::StackTrace().PrintBacktrace();
45 _exit(128 + signal);
46 }
47 #endif // defined(OS_POSIX)
48
49 void ContentBrowserTest::RunTestOnMainThreadLoop() {
50 #if defined(OS_POSIX)
51 signal(SIGTERM, DumpStackTraceSignalHandler);
52 #endif // defined(OS_POSIX)
53
54 // On Mac, without the following autorelease pool, code which is directly
55 // executed (as opposed to executed inside a message loop) would autorelease
56 // objects into a higher-level pool. This pool is not recycled in-sync with
57 // the message loops' pools and causes problems with code relying on
58 // deallocation via an autorelease pool (such as browser window closure and
59 // browser shutdown). To avoid this, the following pool is recycled after each
60 // time code is directly executed.
61 base::mac::ScopedNSAutoreleasePool pool;
62
63 // Pump startup related events.
64 MessageLoopForUI::current()->RunAllPending();
65 pool.Recycle();
66
67 RunTestOnMainThread();
68 pool.Recycle();
69
70 MessageLoopForUI::current()->Quit();
71 pool.Recycle();
72 }
OLDNEW
« no previous file with comments | « content/test/content_browser_test.h ('k') | content/test/content_test_launcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698