[M120 Migration] Set IO|GPU thread type with higher priorites
[platform/framework/web/chromium-efl.git] / gin / array_buffer_unittest.cc
1 // Copyright 2017 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "gin/array_buffer.h"
6
7 #include "base/check_op.h"
8 #include "build/build_config.h"
9 #include "gin/per_isolate_data.h"
10 #include "gin/public/isolate_holder.h"
11 #include "gin/test/v8_test.h"
12
13 namespace gin {
14
15 using ArrayBufferTest = V8Test;
16
17 namespace {
18 const size_t kBufferLength = 65536;
19 }
20
21 // Make sure we can allocate, access and free memory.
22 TEST_F(ArrayBufferTest, AllocateAndFreeBuffer) {
23   v8::Isolate* const isolate = instance_->isolate();
24   v8::ArrayBuffer::Allocator* const allocator =
25       PerIsolateData::From(isolate)->allocator();
26
27   void* buffer = allocator->Allocate(kBufferLength);
28   char* buffer0 = reinterpret_cast<char*>(buffer);
29   *buffer0 = '0';  // ASCII zero
30   CHECK_EQ('0', *buffer0);
31   allocator->Free(buffer, kBufferLength);
32 }
33
34 }  // namespace gin