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

Side by Side Diff: test/unittests/run-all-unittests.cc

Issue 1116633002: Pass ArrayBuffer::Allocator via Isolate::CreateParams (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 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
« no previous file with comments | « test/cctest/test-typedarrays.cc ('k') | test/unittests/test-utils.h » ('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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project 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 "include/libplatform/libplatform.h" 5 #include "include/libplatform/libplatform.h"
6 #include "include/v8.h" 6 #include "include/v8.h"
7 #include "src/base/compiler-specific.h" 7 #include "src/base/compiler-specific.h"
8 #include "testing/gmock/include/gmock/gmock.h" 8 #include "testing/gmock/include/gmock/gmock.h"
9 9
10 #ifdef V8_USE_EXTERNAL_STARTUP_DATA 10 #ifdef V8_USE_EXTERNAL_STARTUP_DATA
11 #include "src/startup-data-util.h" 11 #include "src/startup-data-util.h"
12 #endif // V8_USE_EXTERNAL_STARTUP_DATA 12 #endif // V8_USE_EXTERNAL_STARTUP_DATA
13 13
14 namespace { 14 namespace {
15 15
16 class ArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
17 public:
18 virtual void* Allocate(size_t length) {
19 void* data = AllocateUninitialized(length);
20 return data == NULL ? data : memset(data, 0, length);
21 }
22 virtual void* AllocateUninitialized(size_t length) { return malloc(length); }
23 virtual void Free(void* data, size_t) { free(data); }
24 };
25
26 class DefaultPlatformEnvironment final : public ::testing::Environment { 16 class DefaultPlatformEnvironment final : public ::testing::Environment {
27 public: 17 public:
28 DefaultPlatformEnvironment() : platform_(NULL) {} 18 DefaultPlatformEnvironment() : platform_(NULL) {}
29 ~DefaultPlatformEnvironment() {} 19 ~DefaultPlatformEnvironment() {}
30 20
31 virtual void SetUp() override { 21 virtual void SetUp() override {
32 EXPECT_EQ(NULL, platform_); 22 EXPECT_EQ(NULL, platform_);
33 platform_ = v8::platform::CreateDefaultPlatform(); 23 platform_ = v8::platform::CreateDefaultPlatform();
34 ASSERT_TRUE(platform_ != NULL); 24 ASSERT_TRUE(platform_ != NULL);
35 v8::V8::InitializePlatform(platform_); 25 v8::V8::InitializePlatform(platform_);
36 v8::V8::SetArrayBufferAllocator(&array_buffer_allocator_);
37 ASSERT_TRUE(v8::V8::Initialize()); 26 ASSERT_TRUE(v8::V8::Initialize());
38 } 27 }
39 28
40 virtual void TearDown() override { 29 virtual void TearDown() override {
41 ASSERT_TRUE(platform_ != NULL); 30 ASSERT_TRUE(platform_ != NULL);
42 v8::V8::Dispose(); 31 v8::V8::Dispose();
43 v8::V8::ShutdownPlatform(); 32 v8::V8::ShutdownPlatform();
44 delete platform_; 33 delete platform_;
45 platform_ = NULL; 34 platform_ = NULL;
46 } 35 }
47 36
48 private: 37 private:
49 v8::Platform* platform_; 38 v8::Platform* platform_;
50 ArrayBufferAllocator array_buffer_allocator_;
51 }; 39 };
52 40
53 } // namespace 41 } // namespace
54 42
55 43
56 int main(int argc, char** argv) { 44 int main(int argc, char** argv) {
57 testing::InitGoogleMock(&argc, argv); 45 testing::InitGoogleMock(&argc, argv);
58 testing::AddGlobalTestEnvironment(new DefaultPlatformEnvironment); 46 testing::AddGlobalTestEnvironment(new DefaultPlatformEnvironment);
59 v8::V8::SetFlagsFromCommandLine(&argc, argv, true); 47 v8::V8::SetFlagsFromCommandLine(&argc, argv, true);
60 #ifdef V8_USE_EXTERNAL_STARTUP_DATA 48 #ifdef V8_USE_EXTERNAL_STARTUP_DATA
61 v8::StartupDataHandler startup_data(argv[0], NULL, NULL); 49 v8::StartupDataHandler startup_data(argv[0], NULL, NULL);
62 #endif 50 #endif
63 return RUN_ALL_TESTS(); 51 return RUN_ALL_TESTS();
64 } 52 }
OLDNEW
« no previous file with comments | « test/cctest/test-typedarrays.cc ('k') | test/unittests/test-utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698