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 "base/logging.h" | 5 #include "base/logging.h" |
6 #include "base/macros.h" | 6 #include "base/macros.h" |
7 #include "gin/arguments.h" | 7 #include "gin/arguments.h" |
8 #include "gin/handle.h" | 8 #include "gin/handle.h" |
9 #include "gin/object_template_builder.h" | 9 #include "gin/object_template_builder.h" |
10 #include "gin/per_isolate_data.h" | 10 #include "gin/per_isolate_data.h" |
11 #include "gin/public/isolate_holder.h" | 11 #include "gin/public/isolate_holder.h" |
12 #include "gin/test/v8_test.h" | 12 #include "gin/test/v8_test.h" |
13 #include "gin/try_catch.h" | 13 #include "gin/try_catch.h" |
14 #include "gin/wrappable.h" | 14 #include "gin/wrappable.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
16 | 16 |
17 namespace gin { | 17 namespace gin { |
18 | 18 |
| 19 // This useless base class ensures that the value of a pointer to a MyObject |
| 20 // (below) is not the same as the value of that pointer cast to the object's |
| 21 // WrappableBase base. |
19 class BaseClass { | 22 class BaseClass { |
20 public: | 23 public: |
21 BaseClass() : value_(23) {} | 24 BaseClass() : value_(23) {} |
22 virtual ~BaseClass() {} | 25 virtual ~BaseClass() {} |
23 | 26 |
| 27 // So the compiler doesn't complain that |value_| is unused. |
| 28 int value() const { return value_; } |
| 29 |
24 private: | 30 private: |
25 int value_; | 31 int value_; |
26 | 32 |
27 DISALLOW_COPY_AND_ASSIGN(BaseClass); | 33 DISALLOW_COPY_AND_ASSIGN(BaseClass); |
28 }; | 34 }; |
29 | 35 |
30 class MyObject : public BaseClass, | 36 class MyObject : public BaseClass, |
31 public Wrappable<MyObject> { | 37 public Wrappable<MyObject> { |
32 public: | 38 public: |
33 static WrapperInfo kWrapperInfo; | 39 static WrapperInfo kWrapperInfo; |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 v8::Local<v8::Function> func; | 206 v8::Local<v8::Function> func; |
201 EXPECT_TRUE(ConvertFromV8(isolate, val, &func)); | 207 EXPECT_TRUE(ConvertFromV8(isolate, val, &func)); |
202 v8::Local<v8::Value> argv[] = { | 208 v8::Local<v8::Value> argv[] = { |
203 ConvertToV8(isolate, object.get()) | 209 ConvertToV8(isolate, object.get()) |
204 }; | 210 }; |
205 func->Call(v8::Undefined(isolate), 1, argv); | 211 func->Call(v8::Undefined(isolate), 1, argv); |
206 EXPECT_TRUE(try_catch.HasCaught()); | 212 EXPECT_TRUE(try_catch.HasCaught()); |
207 } | 213 } |
208 | 214 |
209 } // namespace gin | 215 } // namespace gin |
OLD | NEW |