• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/runtime/runtime_test.h"
8 #include "gtest/gtest.h"
9 
10 namespace flutter {
11 namespace testing {
12 
13 using DartVMTest = RuntimeTest;
14 
TEST_F(DartVMTest,SimpleInitialization)15 TEST_F(DartVMTest, SimpleInitialization) {
16   ASSERT_FALSE(DartVMRef::IsInstanceRunning());
17   auto vm = DartVMRef::Create(CreateSettingsForFixture());
18   ASSERT_TRUE(vm);
19 }
20 
TEST_F(DartVMTest,SimpleIsolateNameServer)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 }  // namespace testing
36 }  // namespace flutter
37