| Flutter iOS Embedder |

availability_version_check_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 <tuple>
6
7 #include "flutter/shell/platform/darwin/common/availability_version_check.h"
8
9 #include "gtest/gtest.h"
10
11 TEST(AvailabilityVersionCheck, CanDecodeSystemPlist) {
12 auto maybe_product_version = flutter::ProductVersionFromSystemVersionPList();
13 ASSERT_TRUE(maybe_product_version.has_value());
14 if (maybe_product_version.has_value()) {
15 auto product_version = maybe_product_version.value();
16 ASSERT_GT(product_version, std::make_tuple(0, 0, 0));
17 }
18 }
19
20 static inline uint32_t ConstructVersion(uint32_t major,
21 uint32_t minor,
22 uint32_t subminor) {
23 return ((major & 0xffff) << 16) | ((minor & 0xff) << 8) | (subminor & 0xff);
24 }
25
26 TEST(AvailabilityVersionCheck, CanParseAndCompareVersions) {
27 auto rhs_version = std::make_tuple(17, 2, 0);
28 uint32_t encoded_lower_version = ConstructVersion(12, 3, 7);
29 ASSERT_TRUE(flutter::IsEncodedVersionLessThanOrSame(encoded_lower_version,
30 rhs_version));
31
32 uint32_t encoded_higher_version = ConstructVersion(42, 0, 1);
33 ASSERT_FALSE(flutter::IsEncodedVersionLessThanOrSame(encoded_higher_version,
34 rhs_version));
35 }
TEST
TEST(AvailabilityVersionCheck, CanDecodeSystemPlist)
Definition: availability_version_check_unittests.cc:11
ConstructVersion
static uint32_t ConstructVersion(uint32_t major, uint32_t minor, uint32_t subminor)
Definition: availability_version_check_unittests.cc:20
flutter::ProductVersionFromSystemVersionPList
std::optional< ProductVersion > ProductVersionFromSystemVersionPList()
Definition: availability_version_check.cc:53
availability_version_check.h
flutter::IsEncodedVersionLessThanOrSame
bool IsEncodedVersionLessThanOrSame(uint32_t encoded_lhs, ProductVersion rhs)
Definition: availability_version_check.cc:122