7 #include "gtest/gtest.h"
13 void SetEnvironmentVariable(
const char* key,
const char*
value) {
15 _putenv_s(key,
value);
17 setenv(key,
value, 1);
22 void ClearEnvironmentVariable(
const char* key) {
31 TEST(FlutterProjectBundle, SwitchesEmpty) {
33 ClearEnvironmentVariable(
"FLUTTER_ENGINE_SWITCHES");
38 #ifdef FLUTTER_RELEASE
39 TEST(FlutterProjectBundle, SwitchesIgnoredInRelease) {
40 SetEnvironmentVariable(
"FLUTTER_ENGINE_SWITCHES",
"2");
41 SetEnvironmentVariable(
"FLUTTER_ENGINE_SWITCH_1",
"abc");
42 SetEnvironmentVariable(
"FLUTTER_ENGINE_SWITCH_2",
"foo=\"bar, baz\"");
45 EXPECT_EQ(switches.size(), 0U);
47 #endif // FLUTTER_RELEASE
49 #ifndef FLUTTER_RELEASE
50 TEST(FlutterProjectBundle, Switches) {
51 SetEnvironmentVariable(
"FLUTTER_ENGINE_SWITCHES",
"2");
52 SetEnvironmentVariable(
"FLUTTER_ENGINE_SWITCH_1",
"abc");
53 SetEnvironmentVariable(
"FLUTTER_ENGINE_SWITCH_2",
"foo=\"bar, baz\"");
56 EXPECT_EQ(switches.size(), 2U);
57 EXPECT_EQ(switches[0],
"--abc");
58 EXPECT_EQ(switches[1],
"--foo=\"bar, baz\"");
61 TEST(FlutterProjectBundle, SwitchesExtraValues) {
62 SetEnvironmentVariable(
"FLUTTER_ENGINE_SWITCHES",
"1");
63 SetEnvironmentVariable(
"FLUTTER_ENGINE_SWITCH_1",
"abc");
64 SetEnvironmentVariable(
"FLUTTER_ENGINE_SWITCH_2",
"foo=\"bar, baz\"");
67 EXPECT_EQ(switches.size(), 1U);
68 EXPECT_EQ(switches[0],
"--abc");
71 TEST(FlutterProjectBundle, SwitchesMissingValues) {
72 SetEnvironmentVariable(
"FLUTTER_ENGINE_SWITCHES",
"4");
73 SetEnvironmentVariable(
"FLUTTER_ENGINE_SWITCH_1",
"abc");
74 SetEnvironmentVariable(
"FLUTTER_ENGINE_SWITCH_2",
"foo=\"bar, baz\"");
75 ClearEnvironmentVariable(
"FLUTTER_ENGINE_SWITCH_3");
76 SetEnvironmentVariable(
"FLUTTER_ENGINE_SWITCH_4",
"oops");
79 EXPECT_EQ(switches.size(), 3U);
80 EXPECT_EQ(switches[0],
"--abc");
81 EXPECT_EQ(switches[1],
"--foo=\"bar, baz\"");
84 EXPECT_EQ(switches[2],
"--oops");
86 #endif // !FLUTTER_RELEASE