Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
file_loader_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/testing/dart_isolate_runner.h"
6#include "flutter/testing/fixture_test.h"
7
10
11namespace flutter {
12namespace testing {
13
15
16TEST_F(FileLoaderTest, CanonicalizesFileUrlCorrectly) {
17 ASSERT_FALSE(DartVMRef::IsInstanceRunning());
18 auto settings = CreateSettingsForFixture();
19 auto vm_snapshot = DartSnapshot::VMSnapshotFromSettings(settings);
20 auto isolate_snapshot = DartSnapshot::IsolateSnapshotFromSettings(settings);
21 auto vm_ref = DartVMRef::Create(settings, vm_snapshot, isolate_snapshot);
22 ASSERT_TRUE(vm_ref);
23
24 TaskRunners task_runners(GetCurrentTestName(), //
25 GetCurrentTaskRunner(), //
26 GetCurrentTaskRunner(), //
27 GetCurrentTaskRunner(), //
28 GetCurrentTaskRunner() //
29 );
30 auto isolate = RunDartCodeInIsolate(vm_ref, settings, task_runners, "main",
32 ASSERT_TRUE(isolate);
33
34 ASSERT_TRUE(isolate->RunInIsolateScope([]() {
35 tonic::FileLoader file_loader;
36 std::string original_url = "file:///Users/test/foo";
37 Dart_Handle dart_url = tonic::StdStringToDart(original_url);
38 auto canonicalized_url = file_loader.CanonicalizeURL(Dart_Null(), dart_url);
39 EXPECT_TRUE(canonicalized_url);
40 EXPECT_EQ(tonic::StdStringFromDart(canonicalized_url), original_url);
41 return true;
42 }));
43}
44
45} // namespace testing
46} // namespace flutter
static fml::RefPtr< const DartSnapshot > VMSnapshotFromSettings(const Settings &settings)
From the fields present in the given settings object, infer the core snapshot.
static fml::RefPtr< const DartSnapshot > IsolateSnapshotFromSettings(const Settings &settings)
From the fields present in the given settings object, infer the isolate snapshot.
static DartVMRef Create(const Settings &settings, fml::RefPtr< const DartSnapshot > vm_snapshot=nullptr, fml::RefPtr< const DartSnapshot > isolate_snapshot=nullptr)
static bool IsInstanceRunning()
std::string GetCurrentTestName()
Gets the name of the currently running test. This is useful in generating logs or assets based on tes...
Definition testing.cc:15
TEST_F(DisplayListTest, Defaults)
std::string GetDefaultKernelFilePath()
Returns the default path to kernel_blob.bin. This file is within the directory returned by GetFixture...
Definition testing.cc:19
std::unique_ptr< AutoIsolateShutdown > RunDartCodeInIsolate(DartVMRef &vm_ref, const Settings &settings, const TaskRunners &task_runners, std::string entrypoint, const std::vector< std::string > &args, const std::string &kernel_file_path, fml::WeakPtr< IOManager > io_manager, std::shared_ptr< VolatilePathTracker > volatile_path_tracker, std::unique_ptr< PlatformConfiguration > platform_configuration)