Flutter Engine
The Flutter Engine
dart_vm_unittests.cc
Go to the documentation of this file.
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
7#include "flutter/runtime/dart_vm_lifecycle.h"
8#include "flutter/testing/fixture_test.h"
9#include "gtest/gtest.h"
10
11namespace flutter {
12namespace testing {
13
15
16TEST_F(DartVMTest, SimpleInitialization) {
17 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
18 auto vm = DartVMRef::Create(CreateSettingsForFixture());
19 ASSERT_TRUE(vm);
20}
21
22TEST_F(DartVMTest, SimpleIsolateNameServer) {
23 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
24 auto vm = DartVMRef::Create(CreateSettingsForFixture());
25 ASSERT_TRUE(vm);
26 ASSERT_TRUE(vm.GetVMData());
27 auto ns = vm->GetIsolateNameServer();
28 ASSERT_EQ(ns->LookupIsolatePortByName("foobar").port_id, ILLEGAL_PORT);
29 ASSERT_FALSE(ns->RemoveIsolateNameMapping("foobar"));
30 Dart_PortEx correct_portex = {123, 456};
31 ASSERT_TRUE(ns->RegisterIsolatePortWithName(correct_portex, "foobar"));
32 ASSERT_FALSE(ns->RegisterIsolatePortWithName(correct_portex, "foobar"));
33 Dart_PortEx response = ns->LookupIsolatePortByName("foobar");
34 ASSERT_EQ(response.port_id, correct_portex.port_id);
35 ASSERT_EQ(response.origin_id, correct_portex.origin_id);
36 ASSERT_TRUE(ns->RemoveIsolateNameMapping("foobar"));
37}
38
39TEST_F(DartVMTest, OldGenHeapSize) {
40 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
41 auto settings = CreateSettingsForFixture();
42 settings.old_gen_heap_size = 1024;
43 auto vm = DartVMRef::Create(settings);
44 // There is no way to introspect on the heap size so we just assert the vm was
45 // created.
46 ASSERT_TRUE(vm);
47}
48
49TEST_F(DartVMTest, DisableTimelineEventHandler) {
50 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
52 auto settings = CreateSettingsForFixture();
53 settings.enable_timeline_event_handler = false;
54 auto vm = DartVMRef::Create(settings);
56}
57
58TEST_F(DartVMTest, TraceGetTimelineMicrosDoesNotGetClockWhenSystraceIsEnabled) {
59 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
60 auto settings = CreateSettingsForFixture();
61 settings.trace_systrace = true;
62 auto vm = DartVMRef::Create(settings);
64}
65
66} // namespace testing
67} // namespace flutter
static DartVMRef Create(const Settings &settings, fml::RefPtr< const DartSnapshot > vm_snapshot=nullptr, fml::RefPtr< const DartSnapshot > isolate_snapshot=nullptr)
static bool IsInstanceRunning()
#define ILLEGAL_PORT
Definition: dart_api.h:1535
TEST_F(DisplayListTest, Defaults)
bool TraceHasTimelineEventHandler()
Definition: trace_event.cc:375
void TraceSetTimelineEventHandler(TimelineEventHandler handler)
Definition: trace_event.cc:373
int64_t TraceGetTimelineMicros()
Definition: trace_event.cc:379
int64_t port_id
Definition: dart_api.h:1527
int64_t origin_id
Definition: dart_api.h:1528