1 | // Copyright 2013 The Flutter Authors. All rights reserved. |
---|---|
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 "flutter/runtime/dart_vm.h" |
6 | #include "flutter/runtime/dart_vm_lifecycle.h" |
7 | #include "flutter/testing/fixture_test.h" |
8 | #include "gtest/gtest.h" |
9 | |
10 | namespace flutter { |
11 | namespace testing { |
12 | |
13 | using DartVMTest = FixtureTest; |
14 | |
15 | TEST_F(DartVMTest, SimpleInitialization) { |
16 | ASSERT_FALSE(DartVMRef::IsInstanceRunning()); |
17 | auto vm = DartVMRef::Create(CreateSettingsForFixture()); |
18 | ASSERT_TRUE(vm); |
19 | } |
20 | |
21 | TEST_F(DartVMTest, SimpleIsolateNameServer) { |
22 | ASSERT_FALSE(DartVMRef::IsInstanceRunning()); |
23 | auto vm = DartVMRef::Create(CreateSettingsForFixture()); |
24 | ASSERT_TRUE(vm); |
25 | ASSERT_TRUE(vm.GetVMData()); |
26 | auto ns = vm->GetIsolateNameServer(); |
27 | ASSERT_EQ(ns->LookupIsolatePortByName("foobar"), ILLEGAL_PORT); |
28 | ASSERT_FALSE(ns->RemoveIsolateNameMapping("foobar")); |
29 | ASSERT_TRUE(ns->RegisterIsolatePortWithName(123, "foobar")); |
30 | ASSERT_FALSE(ns->RegisterIsolatePortWithName(123, "foobar")); |
31 | ASSERT_EQ(ns->LookupIsolatePortByName("foobar"), 123); |
32 | ASSERT_TRUE(ns->RemoveIsolateNameMapping("foobar")); |
33 | } |
34 | |
35 | TEST_F(DartVMTest, OldGenHeapSize) { |
36 | ASSERT_FALSE(DartVMRef::IsInstanceRunning()); |
37 | auto settings = CreateSettingsForFixture(); |
38 | settings.old_gen_heap_size = 1024; |
39 | auto vm = DartVMRef::Create(settings); |
40 | // There is no way to introspect on the heap size so we just assert the vm was |
41 | // created. |
42 | ASSERT_TRUE(vm); |
43 | } |
44 | |
45 | } // namespace testing |
46 | } // namespace flutter |
47 |