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

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
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 void ContentBrowserTest::SetUp() {
13 DCHECK(!content::GetContentClient());
14 content_client_.reset(new TestContentClient);
15 content::SetContentClient(content_client_.get());
16
17 content_browser_client_.reset(new content::MockContentBrowserClient());
18 content_client_->set_browser(content_browser_client_.get());
19
20 BrowserTestBase::SetUp();
21 }
22
23 void ContentBrowserTest::TearDown() {
24 BrowserTestBase::TearDown();
25
26 DCHECK_EQ(content_client_.get(), content::GetContentClient());
27 content::SetContentClient(NULL);
28 content_client_.reset();
29
30 content_browser_client_.reset();
31 }
32
33 #if defined(OS_POSIX)
34 // On SIGTERM (sent by the runner on timeouts), dump a stack trace (to make
35 // debugging easier) and also exit with a known error code (so that the test
36 // framework considers this a failure -- http://crbug.com/57578).
37 static void DumpStackTraceSignalHandler(int signal) {
38 base::debug::StackTrace().PrintBacktrace();
39 _exit(128 + signal);
40 }
41 #endif // defined(OS_POSIX)
42
43 void ContentBrowserTest::RunTestOnMainThreadLoop() {
44 #if defined(OS_POSIX)
45 signal(SIGTERM, DumpStackTraceSignalHandler);
46 #endif // defined(OS_POSIX)
47
48 // On Mac, without the following autorelease pool, code which is directly
49 // executed (as opposed to executed inside a message loop) would autorelease
50 // objects into a higher-level pool. This pool is not recycled in-sync with
51 // the message loops' pools and causes problems with code relying on
52 // deallocation via an autorelease pool (such as browser window closure and
53 // browser shutdown). To avoid this, the following pool is recycled after each
54 // time code is directly executed.
55 base::mac::ScopedNSAutoreleasePool pool;
56
57 // Pump startup related events.
58 MessageLoopForUI::current()->RunAllPending();
59 pool.Recycle();
60
61 RunTestOnMainThread();
62 pool.Recycle();
63
64 MessageLoopForUI::current()->Quit();
65 pool.Recycle();
66 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698