-
Notifications
You must be signed in to change notification settings - Fork 6k
/
dart_vm_unittests.cc
67 lines (57 loc) · 2.35 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// Copyright 2013 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 "flutter/runtime/dart_vm_lifecycle.h"
#include "flutter/testing/fixture_test.h"
#include "gtest/gtest.h"
namespace flutter {
namespace testing {
using DartVMTest = FixtureTest;
TEST_F(DartVMTest, SimpleInitialization) {
ASSERT_FALSE(DartVMRef::IsInstanceRunning());
auto vm = DartVMRef::Create(CreateSettingsForFixture());
ASSERT_TRUE(vm);
}
TEST_F(DartVMTest, SimpleIsolateNameServer) {
ASSERT_FALSE(DartVMRef::IsInstanceRunning());
auto vm = DartVMRef::Create(CreateSettingsForFixture());
ASSERT_TRUE(vm);
ASSERT_TRUE(vm.GetVMData());
auto ns = vm->GetIsolateNameServer();
ASSERT_EQ(ns->LookupIsolatePortByName("foobar").port_id, ILLEGAL_PORT);
ASSERT_FALSE(ns->RemoveIsolateNameMapping("foobar"));
Dart_PortEx correct_portex = {123, 456};
ASSERT_TRUE(ns->RegisterIsolatePortWithName(correct_portex, "foobar"));
ASSERT_FALSE(ns->RegisterIsolatePortWithName(correct_portex, "foobar"));
Dart_PortEx response = ns->LookupIsolatePortByName("foobar");
ASSERT_EQ(response.port_id, correct_portex.port_id);
ASSERT_EQ(response.origin_id, correct_portex.origin_id);
ASSERT_TRUE(ns->RemoveIsolateNameMapping("foobar"));
}
TEST_F(DartVMTest, OldGenHeapSize) {
ASSERT_FALSE(DartVMRef::IsInstanceRunning());
auto settings = CreateSettingsForFixture();
settings.old_gen_heap_size = 1024;
auto vm = DartVMRef::Create(settings);
// There is no way to introspect on the heap size so we just assert the vm was
// created.
ASSERT_TRUE(vm);
}
TEST_F(DartVMTest, DisableTimelineEventHandler) {
ASSERT_FALSE(DartVMRef::IsInstanceRunning());
fml::tracing::TraceSetTimelineEventHandler(nullptr);
auto settings = CreateSettingsForFixture();
settings.enable_timeline_event_handler = false;
auto vm = DartVMRef::Create(settings);
ASSERT_FALSE(fml::tracing::TraceHasTimelineEventHandler());
}
TEST_F(DartVMTest, TraceGetTimelineMicrosDoesNotGetClockWhenSystraceIsEnabled) {
ASSERT_FALSE(DartVMRef::IsInstanceRunning());
auto settings = CreateSettingsForFixture();
settings.trace_systrace = true;
auto vm = DartVMRef::Create(settings);
ASSERT_EQ(-1, fml::tracing::TraceGetTimelineMicros());
}
} // namespace testing
} // namespace flutter