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

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

Issue 193072: Move StringPiece into the base namespace. It is colliding (Closed)
Patch Set: take 2 Created 11 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 unified diff | Download patch
« no previous file with comments | « chrome/renderer/user_script_slave.cc ('k') | chrome/test/v8_unit_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #ifndef CHROME_TEST_V8_UNIT_TEST_H_ 5 #ifndef CHROME_TEST_V8_UNIT_TEST_H_
6 #define CHROME_TEST_V8_UNIT_TEST_H_ 6 #define CHROME_TEST_V8_UNIT_TEST_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 #include "v8/include/v8.h" 11 #include "v8/include/v8.h"
12 12
13 namespace base {
13 class StringPiece; 14 class StringPiece;
15 }
14 16
15 // A superclass for unit tests that involve running JavaScript. This class 17 // A superclass for unit tests that involve running JavaScript. This class
16 // sets up V8 context and has methods that make it easy to execute scripts in 18 // sets up V8 context and has methods that make it easy to execute scripts in
17 // this context as well as call functions in the context. 19 // this context as well as call functions in the context.
18 class V8UnitTest : public testing::Test { 20 class V8UnitTest : public testing::Test {
19 public: 21 public:
20 V8UnitTest() {} 22 V8UnitTest() {}
21 virtual void SetUp(); 23 virtual void SetUp();
22 24
23 protected: 25 protected:
24 // Executes the given script source in the context. The specified script 26 // Executes the given script source in the context. The specified script
25 // name is used when reporting errors. 27 // name is used when reporting errors.
26 virtual void ExecuteScriptInContext(const StringPiece& script_source, 28 virtual void ExecuteScriptInContext(const base::StringPiece& script_source,
27 const StringPiece& script_name); 29 const base::StringPiece& script_name);
28 30
29 // Converts a v8::TryCatch into a human readable string. 31 // Converts a v8::TryCatch into a human readable string.
30 virtual std::string ExceptionToString(v8::TryCatch* try_catch); 32 virtual std::string ExceptionToString(v8::TryCatch* try_catch);
31 33
32 // Calls the specified function that resides in the global scope of the 34 // Calls the specified function that resides in the global scope of the
33 // context. If the function throws an exception, FAIL() is called to 35 // context. If the function throws an exception, FAIL() is called to
34 // indicate a unit test failure. This is useful for executing unit test 36 // indicate a unit test failure. This is useful for executing unit test
35 // functions implemented in JavaScript. 37 // functions implemented in JavaScript.
36 virtual void TestFunction(const std::string& function_name); 38 virtual void TestFunction(const std::string& function_name);
37 39
38 // This method is bound to a global function "log" in the context. 40 // This method is bound to a global function "log" in the context.
39 // Scripts running in the context can call this to print out logging 41 // Scripts running in the context can call this to print out logging
40 // information to the console. 42 // information to the console.
41 static v8::Handle<v8::Value> Log(const v8::Arguments& args); 43 static v8::Handle<v8::Value> Log(const v8::Arguments& args);
42 44
43 // Handle scope that is used throughout the life of this class. 45 // Handle scope that is used throughout the life of this class.
44 v8::HandleScope handle_scope_; 46 v8::HandleScope handle_scope_;
45 47
46 // Context for the JavaScript in the test. 48 // Context for the JavaScript in the test.
47 v8::Handle<v8::Context> context_; 49 v8::Handle<v8::Context> context_;
48 }; 50 };
49 51
50 #endif // CHROME_TEST_V8_UNIT_TEST_H_ 52 #endif // CHROME_TEST_V8_UNIT_TEST_H_
OLDNEW
« no previous file with comments | « chrome/renderer/user_script_slave.cc ('k') | chrome/test/v8_unit_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698