Always set NSTexturedBackgroundWindowMask on app windows.
[chromium-blink-merge.git] / tools / gn / escape_unittest.cc
blob7ba0af060d18099de347dee1297c86a5c35ba700
1 // Copyright (c) 2013 The Chromium 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.
5 #include "testing/gtest/include/gtest/gtest.h"
6 #include "tools/gn/escape.h"
8 TEST(Escape, Ninja) {
9 EscapeOptions opts;
10 opts.mode = ESCAPE_NINJA;
11 std::string result = EscapeString("asdf: \"$\\bar", opts, NULL);
12 EXPECT_EQ("asdf$:$ \"$$\\bar", result);
15 TEST(Escape, Shell) {
16 EscapeOptions opts;
17 opts.mode = ESCAPE_SHELL;
18 std::string result = EscapeString("asdf: \"$\\bar", opts, NULL);
19 #if defined(OS_WIN)
20 // Windows shell doesn't escape backslashes, but it does backslash-escape
21 // quotes.
22 EXPECT_EQ("\"asdf: \\\"$\\bar\"", result);
23 #else
24 EXPECT_EQ("\"asdf: \\\"$\\\\bar\"", result);
25 #endif
28 TEST(Escape, UsedQuotes) {
29 EscapeOptions shell_options;
30 shell_options.mode = ESCAPE_SHELL;
32 EscapeOptions ninja_options;
33 ninja_options.mode = ESCAPE_NINJA;
35 EscapeOptions ninja_shell_options;
36 ninja_shell_options.mode = ESCAPE_NINJA_SHELL;
38 // Shell escaping with quoting inhibited.
39 bool used_quotes = false;
40 shell_options.inhibit_quoting = true;
41 EXPECT_EQ("foo bar", EscapeString("foo bar", shell_options, &used_quotes));
42 EXPECT_TRUE(used_quotes);
44 // Shell escaping with regular quoting.
45 used_quotes = false;
46 shell_options.inhibit_quoting = false;
47 EXPECT_EQ("\"foo bar\"",
48 EscapeString("foo bar", shell_options, &used_quotes));
49 EXPECT_TRUE(used_quotes);
51 // Ninja shell escaping should be the same.
52 used_quotes = false;
53 EXPECT_EQ("\"foo$ bar\"",
54 EscapeString("foo bar", ninja_shell_options, &used_quotes));
55 EXPECT_TRUE(used_quotes);
57 // Ninja escaping shouldn't use quoting.
58 used_quotes = false;
59 EXPECT_EQ("foo$ bar", EscapeString("foo bar", ninja_options, &used_quotes));
60 EXPECT_FALSE(used_quotes);
62 // Used quotes not reset if it's already true.
63 used_quotes = true;
64 EscapeString("foo", ninja_options, &used_quotes);
65 EXPECT_TRUE(used_quotes);