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

Unified Diff: base/test/test_launcher.cc

Issue 23450018: test launcher: Fix running a single test using filter. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/test/test_launcher.cc
diff --git a/base/test/test_launcher.cc b/base/test/test_launcher.cc
index b131506b026bc658b02edeaba95bec4388a31df6..deabb9a4add1dc1b8ed692d08b5cb6466f4be403 100644
--- a/base/test/test_launcher.cc
+++ b/base/test/test_launcher.cc
@@ -128,6 +128,8 @@ class ResultsPrinter {
// Adds |result| to the stored test results.
void AddTestResult(const TestResult& result);
+ WeakPtr<ResultsPrinter> GetWeakPtr();
+
private:
// Prints a list of tests that finished with |status|.
void PrintTestsByStatus(TestResult::Status status,
@@ -153,6 +155,8 @@ class ResultsPrinter {
ThreadChecker thread_checker_;
+ WeakPtrFactory<ResultsPrinter> weak_ptr_;
+
DISALLOW_COPY_AND_ASSIGN(ResultsPrinter);
};
@@ -161,7 +165,8 @@ ResultsPrinter::ResultsPrinter(const CommandLine& command_line,
: test_started_count_(0),
test_run_count_(0),
out_(NULL),
- callback_(callback) {
+ callback_(callback),
+ weak_ptr_(this) {
if (!command_line.HasSwitch(kGTestOutputFlag))
return;
std::string flag = command_line.GetSwitchValueASCII(kGTestOutputFlag);
@@ -291,6 +296,10 @@ void ResultsPrinter::AddTestResult(const TestResult& result) {
}
}
+WeakPtr<ResultsPrinter> ResultsPrinter::GetWeakPtr() {
+ return weak_ptr_.GetWeakPtr();
+}
+
void ResultsPrinter::PrintTestsByStatus(TestResult::Status status,
const std::string& description) {
DCHECK(thread_checker_.CalledOnValidThread());
@@ -424,7 +433,7 @@ void RunTests(TestLauncherDelegate* launcher_delegate,
MessageLoop::current()->PostTask(
FROM_HERE,
- Bind(&ResultsPrinter::OnAllTestsStarted, Unretained(printer)));
+ Bind(&ResultsPrinter::OnAllTestsStarted, printer->GetWeakPtr()));
}
void RunTestIteration(TestLauncherDelegate* launcher_delegate,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698