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

Side by Side Diff: chrome/test/v8_unit_test.cc

Issue 7016011: iwyu: Include stringprintf.h where appropriate, part 3. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Win fix. Created 9 years, 7 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
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/string_util.h" 5 #include "base/stringprintf.h"
6 #include "base/string_piece.h"
6 #include "chrome/test/v8_unit_test.h" 7 #include "chrome/test/v8_unit_test.h"
7 8
8 V8UnitTest::V8UnitTest() {} 9 V8UnitTest::V8UnitTest() {}
9 10
10 V8UnitTest::~V8UnitTest() {} 11 V8UnitTest::~V8UnitTest() {}
11 12
12 void V8UnitTest::SetUp() { 13 void V8UnitTest::SetUp() {
13 v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New(); 14 v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New();
14 global->Set(v8::String::New("log"), 15 global->Set(v8::String::New("log"),
15 v8::FunctionTemplate::New(&V8UnitTest::Log)); 16 v8::FunctionTemplate::New(&V8UnitTest::Log));
(...skipping 28 matching lines...) Expand all
44 FAIL() << ExceptionToString(&try_catch); 45 FAIL() << ExceptionToString(&try_catch);
45 } 46 }
46 } 47 }
47 48
48 std::string V8UnitTest::ExceptionToString(v8::TryCatch* try_catch) { 49 std::string V8UnitTest::ExceptionToString(v8::TryCatch* try_catch) {
49 std::string str; 50 std::string str;
50 v8::HandleScope handle_scope; 51 v8::HandleScope handle_scope;
51 v8::String::Utf8Value exception(try_catch->Exception()); 52 v8::String::Utf8Value exception(try_catch->Exception());
52 v8::Handle<v8::Message> message = try_catch->Message(); 53 v8::Handle<v8::Message> message = try_catch->Message();
53 if (message.IsEmpty()) { 54 if (message.IsEmpty()) {
54 str.append(StringPrintf("%s\n", *exception)); 55 str.append(base::StringPrintf("%s\n", *exception));
55 } else { 56 } else {
56 v8::String::Utf8Value filename(message->GetScriptResourceName()); 57 v8::String::Utf8Value filename(message->GetScriptResourceName());
57 int linenum = message->GetLineNumber(); 58 int linenum = message->GetLineNumber();
58 int colnum = message->GetStartColumn(); 59 int colnum = message->GetStartColumn();
59 str.append(StringPrintf("%s:%i:%i %s\n", *filename, linenum, colnum, 60 str.append(base::StringPrintf(
60 *exception)); 61 "%s:%i:%i %s\n", *filename, linenum, colnum, *exception));
61 v8::String::Utf8Value sourceline(message->GetSourceLine()); 62 v8::String::Utf8Value sourceline(message->GetSourceLine());
62 str.append(StringPrintf("%s\n", *sourceline)); 63 str.append(base::StringPrintf("%s\n", *sourceline));
63 } 64 }
64 return str; 65 return str;
65 } 66 }
66 67
67 void V8UnitTest::TestFunction(const std::string& function_name) { 68 void V8UnitTest::TestFunction(const std::string& function_name) {
68 v8::Context::Scope context_scope(context_); 69 v8::Context::Scope context_scope(context_);
69 v8::HandleScope handle_scope; 70 v8::HandleScope handle_scope;
70 71
71 v8::Handle<v8::Value> functionProperty = 72 v8::Handle<v8::Value> functionProperty =
72 context_->Global()->Get(v8::String::New(function_name.c_str())); 73 context_->Global()->Get(v8::String::New(function_name.c_str()));
(...skipping 20 matching lines...) Expand all
93 first = false; 94 first = false;
94 } else { 95 } else {
95 message += " "; 96 message += " ";
96 } 97 }
97 v8::String::Utf8Value str(args[i]); 98 v8::String::Utf8Value str(args[i]);
98 message += *str; 99 message += *str;
99 } 100 }
100 std::cout << message << "\n"; 101 std::cout << message << "\n";
101 return v8::Undefined(); 102 return v8::Undefined();
102 } 103 }
OLDNEW
« no previous file with comments | « chrome/test/sync/engine/mock_connection_manager.cc ('k') | chrome/tools/convert_dict/convert_dict_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698