Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
build_info_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 "build_info.h"
6
7#include <gmock/gmock.h>
8#include <gtest/gtest.h>
9#include <lib/async-loop/cpp/loop.h>
10#include <lib/async-loop/default.h>
11#include <lib/inspect/cpp/reader.h>
12
13const std::string& inspect_node_name = "build_info_unittests";
14
15void checkProperty(inspect::Hierarchy& root,
16 const std::string& name,
17 const std::string& expected_value) {
18 const inspect::Hierarchy* build_info = root.GetByPath({inspect_node_name});
19 EXPECT_TRUE(build_info != nullptr);
20 auto* actual_value =
21 build_info->node().get_property<inspect::StringPropertyValue>(name);
22 EXPECT_TRUE(actual_value != nullptr);
23 EXPECT_EQ(actual_value->value(), expected_value);
24}
25
26namespace dart_utils {
27
28class BuildInfoTest : public ::testing::Test {
29 public:
30 static void SetUpTestSuite() {
31 async::Loop loop(&kAsyncLoopConfigAttachToCurrentThread);
32 auto context = sys::ComponentContext::Create();
33 RootInspectNode::Initialize(context.get());
34 }
35};
36
37TEST_F(BuildInfoTest, AllPropertiesAreDefined) {
38 EXPECT_NE(BuildInfo::DartSdkGitRevision(), "{{DART_SDK_GIT_REVISION}}");
40 "{{DART_SDK_SEMANTIC_VERSION}}");
42 "{{FLUTTER_ENGINE_GIT_REVISION}}");
43 EXPECT_NE(BuildInfo::FuchsiaSdkVersion(), "{{FUCHSIA_SDK_VERSION}}");
44}
45
46TEST_F(BuildInfoTest, AllPropertiesAreDumped) {
47 inspect::Node node =
49 BuildInfo::Dump(node);
50 inspect::Hierarchy root =
51 inspect::ReadFromVmo(
52 std::move(
54 .take_value();
55 checkProperty(root, "dart_sdk_git_revision", BuildInfo::DartSdkGitRevision());
56 checkProperty(root, "dart_sdk_semantic_version",
58 checkProperty(root, "flutter_engine_git_revision",
60 checkProperty(root, "fuchsia_sdk_version", BuildInfo::FuchsiaSdkVersion());
61}
62
63} // namespace dart_utils
const std::string & inspect_node_name
void checkProperty(inspect::Hierarchy &root, const std::string &name, const std::string &expected_value)
static void Dump(inspect::Node &node)
static const char * FuchsiaSdkVersion()
static const char * DartSdkSemanticVersion()
static const char * FlutterEngineGitRevision()
static const char * DartSdkGitRevision()
static inspect::Inspector * GetInspector()
static void Initialize(sys::ComponentContext *context)
static inspect::Node CreateRootChild(const std::string &name)
static const char * expected_value
const char * name
Definition fuchsia.cc:50
TEST_F(BuildInfoTest, AllPropertiesAreDefined)
#define EXPECT_TRUE(handle)
Definition unit_test.h:685