OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "gin/test/gtest.h" | 5 #include "gin/test/gtest.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "gin/arguments.h" | 9 #include "gin/arguments.h" |
10 #include "gin/converter.h" | 10 #include "gin/converter.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 } | 24 } |
25 | 25 |
26 void ExpectTrue(bool condition, const std::string& description) { | 26 void ExpectTrue(bool condition, const std::string& description) { |
27 EXPECT_TRUE(condition) << description; | 27 EXPECT_TRUE(condition) << description; |
28 } | 28 } |
29 | 29 |
30 void ExpectFalse(bool condition, const std::string& description) { | 30 void ExpectFalse(bool condition, const std::string& description) { |
31 EXPECT_FALSE(condition) << description; | 31 EXPECT_FALSE(condition) << description; |
32 } | 32 } |
33 | 33 |
34 void ExpectEqual(const v8::Handle<v8::Value> expected, | 34 void ExpectEqual(const v8::Local<v8::Value> expected, |
35 const v8::Handle<v8::Value> actual, | 35 const v8::Local<v8::Value> actual, |
36 const std::string& description) { | 36 const std::string& description) { |
37 EXPECT_TRUE(expected->StrictEquals(actual)) << description; | 37 EXPECT_TRUE(expected->StrictEquals(actual)) << description; |
38 } | 38 } |
39 | 39 |
40 WrapperInfo g_wrapper_info = { kEmbedderNativeGin }; | 40 WrapperInfo g_wrapper_info = { kEmbedderNativeGin }; |
41 | 41 |
42 } // namespace | 42 } // namespace |
43 | 43 |
44 const char GTest::kModuleName[] = "gtest"; | 44 const char GTest::kModuleName[] = "gtest"; |
45 | 45 |
46 v8::Local<v8::Value> GTest::GetModule(v8::Isolate* isolate) { | 46 v8::Local<v8::Value> GTest::GetModule(v8::Isolate* isolate) { |
47 PerIsolateData* data = PerIsolateData::From(isolate); | 47 PerIsolateData* data = PerIsolateData::From(isolate); |
48 v8::Local<v8::ObjectTemplate> templ = | 48 v8::Local<v8::ObjectTemplate> templ = |
49 data->GetObjectTemplate(&g_wrapper_info); | 49 data->GetObjectTemplate(&g_wrapper_info); |
50 if (templ.IsEmpty()) { | 50 if (templ.IsEmpty()) { |
51 templ = ObjectTemplateBuilder(isolate) | 51 templ = ObjectTemplateBuilder(isolate) |
52 .SetMethod("fail", Fail) | 52 .SetMethod("fail", Fail) |
53 .SetMethod("expectTrue", ExpectTrue) | 53 .SetMethod("expectTrue", ExpectTrue) |
54 .SetMethod("expectFalse", ExpectFalse) | 54 .SetMethod("expectFalse", ExpectFalse) |
55 .SetMethod("expectEqual", ExpectEqual) | 55 .SetMethod("expectEqual", ExpectEqual) |
56 .Build(); | 56 .Build(); |
57 data->SetObjectTemplate(&g_wrapper_info, templ); | 57 data->SetObjectTemplate(&g_wrapper_info, templ); |
58 } | 58 } |
59 return templ->NewInstance(); | 59 return templ->NewInstance(); |
60 } | 60 } |
61 | 61 |
62 } // namespace gin | 62 } // namespace gin |
OLD | NEW |