Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(75)

Side by Side Diff: tools/gn/function_get_target_outputs_unittest.cc

Issue 2972113002: Remove ScopedVector from tools/gn/. (Closed)
Patch Set: Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/gn/function_get_target_outputs.cc ('k') | tools/gn/function_toolchain.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <utility>
6
7 #include "base/memory/ptr_util.h"
5 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
6 #include "tools/gn/functions.h" 9 #include "tools/gn/functions.h"
7 #include "tools/gn/target.h" 10 #include "tools/gn/target.h"
8 #include "tools/gn/test_with_scope.h" 11 #include "tools/gn/test_with_scope.h"
9 12
10 namespace { 13 namespace {
11 14
12 class GetTargetOutputsTest : public testing::Test { 15 class GetTargetOutputsTest : public testing::Test {
13 public: 16 public:
14 GetTargetOutputsTest() { 17 GetTargetOutputsTest() {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 53
51 protected: 54 protected:
52 TestWithScope setup_; 55 TestWithScope setup_;
53 56
54 Scope::ItemVector items_; 57 Scope::ItemVector items_;
55 }; 58 };
56 59
57 } // namespace 60 } // namespace
58 61
59 TEST_F(GetTargetOutputsTest, Copy) { 62 TEST_F(GetTargetOutputsTest, Copy) {
60 Target* action = new Target(setup_.settings(), GetLabel("//foo/", "bar"), {}); 63 auto action = base::MakeUnique<Target>(
64 setup_.settings(), GetLabel("//foo/", "bar"), InputFileSet{});
61 action->set_output_type(Target::COPY_FILES); 65 action->set_output_type(Target::COPY_FILES);
62 action->sources().push_back(SourceFile("//file.txt")); 66 action->sources().push_back(SourceFile("//file.txt"));
63 action->action_values().outputs() = 67 action->action_values().outputs() =
64 SubstitutionList::MakeForTest("//out/Debug/{{source_file_part}}.one"); 68 SubstitutionList::MakeForTest("//out/Debug/{{source_file_part}}.one");
65 69
66 items_.push_back(action); 70 items_.push_back(std::move(action));
67 71
68 Err err; 72 Err err;
69 Value result = GetTargetOutputs("//foo:bar", &err); 73 Value result = GetTargetOutputs("//foo:bar", &err);
70 ASSERT_FALSE(err.has_error()); 74 ASSERT_FALSE(err.has_error());
71 AssertSingleStringEquals(result, "//out/Debug/file.txt.one"); 75 AssertSingleStringEquals(result, "//out/Debug/file.txt.one");
72 } 76 }
73 77
74 TEST_F(GetTargetOutputsTest, Action) { 78 TEST_F(GetTargetOutputsTest, Action) {
75 Target* action = new Target(setup_.settings(), GetLabel("//foo/", "bar"), {}); 79 auto action = base::MakeUnique<Target>(
80 setup_.settings(), GetLabel("//foo/", "bar"), InputFileSet{});
76 action->set_output_type(Target::ACTION); 81 action->set_output_type(Target::ACTION);
77 action->action_values().outputs() = SubstitutionList::MakeForTest( 82 action->action_values().outputs() = SubstitutionList::MakeForTest(
78 "//output1.txt", 83 "//output1.txt",
79 "//output2.txt"); 84 "//output2.txt");
80 85
81 items_.push_back(action); 86 items_.push_back(std::move(action));
82 87
83 Err err; 88 Err err;
84 Value result = GetTargetOutputs("//foo:bar", &err); 89 Value result = GetTargetOutputs("//foo:bar", &err);
85 ASSERT_FALSE(err.has_error()); 90 ASSERT_FALSE(err.has_error());
86 AssertTwoStringsEqual(result, "//output1.txt", "//output2.txt"); 91 AssertTwoStringsEqual(result, "//output1.txt", "//output2.txt");
87 } 92 }
88 93
89 TEST_F(GetTargetOutputsTest, ActionForeach) { 94 TEST_F(GetTargetOutputsTest, ActionForeach) {
90 Target* action = new Target(setup_.settings(), GetLabel("//foo/", "bar"), {}); 95 auto action = base::MakeUnique<Target>(
96 setup_.settings(), GetLabel("//foo/", "bar"), InputFileSet{});
91 action->set_output_type(Target::ACTION_FOREACH); 97 action->set_output_type(Target::ACTION_FOREACH);
92 action->sources().push_back(SourceFile("//file.txt")); 98 action->sources().push_back(SourceFile("//file.txt"));
93 action->action_values().outputs() = SubstitutionList::MakeForTest( 99 action->action_values().outputs() = SubstitutionList::MakeForTest(
94 "//out/Debug/{{source_file_part}}.one", 100 "//out/Debug/{{source_file_part}}.one",
95 "//out/Debug/{{source_file_part}}.two"); 101 "//out/Debug/{{source_file_part}}.two");
96 102
97 items_.push_back(action); 103 items_.push_back(std::move(action));
98 104
99 Err err; 105 Err err;
100 Value result = GetTargetOutputs("//foo:bar", &err); 106 Value result = GetTargetOutputs("//foo:bar", &err);
101 ASSERT_FALSE(err.has_error()); 107 ASSERT_FALSE(err.has_error());
102 AssertTwoStringsEqual(result, "//out/Debug/file.txt.one", 108 AssertTwoStringsEqual(result, "//out/Debug/file.txt.one",
103 "//out/Debug/file.txt.two"); 109 "//out/Debug/file.txt.two");
104 } 110 }
OLDNEW
« no previous file with comments | « tools/gn/function_get_target_outputs.cc ('k') | tools/gn/function_toolchain.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698