OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 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 "testing/gtest/include/gtest/gtest.h" | 5 #include "testing/gtest/include/gtest/gtest.h" |
6 #include "tools/gn/builder.h" | 6 #include "tools/gn/builder.h" |
7 #include "tools/gn/loader.h" | 7 #include "tools/gn/loader.h" |
8 #include "tools/gn/target.h" | 8 #include "tools/gn/target.h" |
9 #include "tools/gn/test_with_scope.h" | 9 #include "tools/gn/test_with_scope.h" |
10 #include "tools/gn/toolchain.h" | 10 #include "tools/gn/toolchain.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 } | 28 } |
29 virtual const Settings* GetToolchainSettings( | 29 virtual const Settings* GetToolchainSettings( |
30 const Label& label) const OVERRIDE { | 30 const Label& label) const OVERRIDE { |
31 return NULL; | 31 return NULL; |
32 } | 32 } |
33 | 33 |
34 bool HasLoadedNone() const { | 34 bool HasLoadedNone() const { |
35 return files_.empty(); | 35 return files_.empty(); |
36 } | 36 } |
37 | 37 |
38 // Returns true if one load has been requested and it matches the given | 38 // Returns true if two loads have been requested and they match the given |
39 // file. This will clear the records so it will be empty for the next call. | 39 // file. This will clear the records so it will be empty for the next call. |
40 bool HasLoadedOne(const SourceFile& f) { | |
41 if (files_.size() != 1u) { | |
42 files_.clear(); | |
43 return false; | |
44 } | |
45 | |
46 bool match = (files_[0] == f); | |
47 files_.clear(); | |
48 return match; | |
49 } | |
50 | |
51 // Like HasLoadedOne above. Accepts any ordering. | |
52 bool HasLoadedTwo(const SourceFile& a, const SourceFile& b) { | 40 bool HasLoadedTwo(const SourceFile& a, const SourceFile& b) { |
53 if (files_.size() != 2u) { | 41 if (files_.size() != 2u) { |
54 files_.clear(); | 42 files_.clear(); |
55 return false; | 43 return false; |
56 } | 44 } |
57 | 45 |
58 bool match = ( | 46 bool match = ( |
59 (files_[0] == a && files_[1] == b) || | 47 (files_[0] == a && files_[1] == b) || |
60 (files_[0] == b && files_[0] == a)); | 48 (files_[0] == b && files_[0] == a)); |
61 files_.clear(); | 49 files_.clear(); |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 a->set_output_type(Target::EXECUTABLE); | 206 a->set_output_type(Target::EXECUTABLE); |
219 builder_->ItemDefined(scoped_ptr<Item>(a)); | 207 builder_->ItemDefined(scoped_ptr<Item>(a)); |
220 | 208 |
221 // A should have the generate bit set since it's in the default toolchain. | 209 // A should have the generate bit set since it's in the default toolchain. |
222 BuilderRecord* a_record = builder_->GetRecord(a_label); | 210 BuilderRecord* a_record = builder_->GetRecord(a_label); |
223 EXPECT_TRUE(a_record->should_generate()); | 211 EXPECT_TRUE(a_record->should_generate()); |
224 | 212 |
225 // It should have gotten pushed to B. | 213 // It should have gotten pushed to B. |
226 EXPECT_TRUE(b_record->should_generate()); | 214 EXPECT_TRUE(b_record->should_generate()); |
227 } | 215 } |
OLD | NEW |