Update V8 to version 4.6.61.
[chromium-blink-merge.git] / tools / gn / visibility_unittest.cc
blobe120f74a0404bb9bcf74b05081d6662d005657d1
1 // Copyright 2014 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/err.h"
7 #include "tools/gn/label.h"
8 #include "tools/gn/value.h"
9 #include "tools/gn/visibility.h"
11 TEST(Visibility, CanSeeMe) {
12 Value list(nullptr, Value::LIST);
13 list.list_value().push_back(Value(nullptr, "//rec/*")); // Recursive.
14 list.list_value().push_back(Value(nullptr, "//dir:*")); // One dir.
15 list.list_value().push_back(Value(nullptr, "//my:name")); // Exact match.
17 Err err;
18 Visibility vis;
19 ASSERT_TRUE(vis.Set(SourceDir("//"), list, &err));
21 EXPECT_FALSE(vis.CanSeeMe(Label(SourceDir("//random/"), "thing")));
22 EXPECT_FALSE(vis.CanSeeMe(Label(SourceDir("//my/"), "notname")));
24 EXPECT_TRUE(vis.CanSeeMe(Label(SourceDir("//my/"), "name")));
25 EXPECT_TRUE(vis.CanSeeMe(Label(SourceDir("//rec/"), "anything")));
26 EXPECT_TRUE(vis.CanSeeMe(Label(SourceDir("//rec/a/"), "anything")));
27 EXPECT_TRUE(vis.CanSeeMe(Label(SourceDir("//rec/b/"), "anything")));
28 EXPECT_TRUE(vis.CanSeeMe(Label(SourceDir("//dir/"), "anything")));
29 EXPECT_FALSE(vis.CanSeeMe(Label(SourceDir("//dir/a/"), "anything")));
30 EXPECT_FALSE(vis.CanSeeMe(Label(SourceDir("//directory/"), "anything")));
33 TEST(Visibility, Public) {
34 Err err;
35 Visibility vis;
37 Value list(nullptr, Value::LIST);
38 list.list_value().push_back(Value(nullptr, "*"));
39 ASSERT_TRUE(vis.Set(SourceDir("//"), list, &err));
41 EXPECT_TRUE(vis.CanSeeMe(Label(SourceDir("//random/"), "thing")));
42 EXPECT_TRUE(vis.CanSeeMe(Label(SourceDir("//"), "")));
45 TEST(Visibility, Private) {
46 Err err;
47 Visibility vis;
48 ASSERT_TRUE(vis.Set(SourceDir("//"), Value(nullptr, Value::LIST), &err));
50 EXPECT_FALSE(vis.CanSeeMe(Label(SourceDir("//random/"), "thing")));
51 EXPECT_FALSE(vis.CanSeeMe(Label(SourceDir("//"), "")));