forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dart_vm_unittests.cc
34 lines (29 loc) · 1.2 KB
/
dart_vm_unittests.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Copyright 2017 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "flutter/runtime/dart_vm.h"
#include "gtest/gtest.h"
namespace blink {
TEST(DartVM, SimpleInitialization) {
Settings settings = {};
settings.task_observer_add = [](intptr_t, fml::closure) {};
settings.task_observer_remove = [](intptr_t) {};
auto vm = DartVM::ForProcess(settings);
ASSERT_TRUE(vm);
ASSERT_EQ(vm, DartVM::ForProcess(settings));
ASSERT_FALSE(DartVM::IsRunningPrecompiledCode());
}
TEST(DartVM, SimpleIsolateNameServer) {
Settings settings = {};
settings.task_observer_add = [](intptr_t, fml::closure) {};
settings.task_observer_remove = [](intptr_t) {};
auto vm = DartVM::ForProcess(settings);
auto ns = vm->GetIsolateNameServer();
ASSERT_EQ(ns->LookupIsolatePortByName("foobar"), ILLEGAL_PORT);
ASSERT_FALSE(ns->RemoveIsolateNameMapping("foobar"));
ASSERT_TRUE(ns->RegisterIsolatePortWithName(123, "foobar"));
ASSERT_FALSE(ns->RegisterIsolatePortWithName(123, "foobar"));
ASSERT_EQ(ns->LookupIsolatePortByName("foobar"), 123);
ASSERT_TRUE(ns->RemoveIsolateNameMapping("foobar"));
}
} // namespace blink