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 "tools/gn/target.h" | 5 #include "tools/gn/target.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 #include "tools/gn/build_settings.h" | 10 #include "tools/gn/build_settings.h" |
(...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
756 d.private_deps().push_back(LabelTargetPair(&exe)); | 756 d.private_deps().push_back(LabelTargetPair(&exe)); |
757 d.assert_no_deps().push_back(disallow_a); | 757 d.assert_no_deps().push_back(disallow_a); |
758 ASSERT_TRUE(d.OnResolved(&err)); | 758 ASSERT_TRUE(d.OnResolved(&err)); |
759 | 759 |
760 // A2 disallows depending on anything in its own directory, but the | 760 // A2 disallows depending on anything in its own directory, but the |
761 // assertions should not match the target itself so this should be OK. | 761 // assertions should not match the target itself so this should be OK. |
762 TestTarget a2(setup, "//a:a2", Target::EXECUTABLE); | 762 TestTarget a2(setup, "//a:a2", Target::EXECUTABLE); |
763 a2.assert_no_deps().push_back(disallow_a); | 763 a2.assert_no_deps().push_back(disallow_a); |
764 ASSERT_TRUE(a2.OnResolved(&err)); | 764 ASSERT_TRUE(a2.OnResolved(&err)); |
765 } | 765 } |
| 766 |
| 767 TEST(Target, PullRecursiveBundleData) { |
| 768 TestWithScope setup; |
| 769 Err err; |
| 770 |
| 771 // We have the following dependency graph: |
| 772 // A (create_bundle) -> B (bundle_data) |
| 773 // \-> C (create_bundle) -> D (bundle_data) |
| 774 // \-> E (group) -> F (bundle_data) |
| 775 // \-> B (bundle_data) |
| 776 TestTarget a(setup, "//foo:a", Target::CREATE_BUNDLE); |
| 777 TestTarget b(setup, "//foo:b", Target::BUNDLE_DATA); |
| 778 TestTarget c(setup, "//foo:c", Target::CREATE_BUNDLE); |
| 779 TestTarget d(setup, "//foo:d", Target::BUNDLE_DATA); |
| 780 TestTarget e(setup, "//foo:e", Target::GROUP); |
| 781 TestTarget f(setup, "//foo:f", Target::BUNDLE_DATA); |
| 782 a.public_deps().push_back(LabelTargetPair(&b)); |
| 783 a.public_deps().push_back(LabelTargetPair(&c)); |
| 784 a.public_deps().push_back(LabelTargetPair(&e)); |
| 785 c.public_deps().push_back(LabelTargetPair(&d)); |
| 786 e.public_deps().push_back(LabelTargetPair(&f)); |
| 787 e.public_deps().push_back(LabelTargetPair(&b)); |
| 788 |
| 789 b.sources().push_back(SourceFile("//foo/b1.txt")); |
| 790 b.sources().push_back(SourceFile("//foo/b2.txt")); |
| 791 b.action_values().outputs() = SubstitutionList::MakeForTest( |
| 792 "{{bundle_resources_dir}}/{{source_file_part}}"); |
| 793 ASSERT_TRUE(b.OnResolved(&err)); |
| 794 |
| 795 d.sources().push_back(SourceFile("//foo/d.txt")); |
| 796 d.action_values().outputs() = SubstitutionList::MakeForTest( |
| 797 "{{bundle_resources_dir}}/{{source_file_part}}"); |
| 798 ASSERT_TRUE(d.OnResolved(&err)); |
| 799 |
| 800 f.sources().push_back(SourceFile("//foo/f1.txt")); |
| 801 f.sources().push_back(SourceFile("//foo/f2.txt")); |
| 802 f.sources().push_back(SourceFile("//foo/f3.txt")); |
| 803 f.sources().push_back( |
| 804 SourceFile("//foo/Foo.xcassets/foo.imageset/Contents.json")); |
| 805 f.sources().push_back( |
| 806 SourceFile("//foo/Foo.xcassets/foo.imageset/FooEmpty-29.png")); |
| 807 f.sources().push_back( |
| 808 SourceFile("//foo/Foo.xcassets/foo.imageset/FooEmpty-29@2x.png")); |
| 809 f.sources().push_back( |
| 810 SourceFile("//foo/Foo.xcassets/foo.imageset/FooEmpty-29@3x.png")); |
| 811 f.action_values().outputs() = SubstitutionList::MakeForTest( |
| 812 "{{bundle_resources_dir}}/{{source_file_part}}"); |
| 813 ASSERT_TRUE(f.OnResolved(&err)); |
| 814 |
| 815 ASSERT_TRUE(e.OnResolved(&err)); |
| 816 ASSERT_TRUE(c.OnResolved(&err)); |
| 817 ASSERT_TRUE(a.OnResolved(&err)); |
| 818 |
| 819 // A gets its data from B and F. |
| 820 ASSERT_EQ(a.bundle_data().file_rules().size(), 2u); |
| 821 ASSERT_EQ(a.bundle_data().file_rules()[0].sources().size(), 2u); |
| 822 ASSERT_EQ(a.bundle_data().file_rules()[1].sources().size(), 3u); |
| 823 ASSERT_EQ(a.bundle_data().asset_catalog_sources().size(), 4u); |
| 824 |
| 825 // C gets its data from D. |
| 826 ASSERT_EQ(c.bundle_data().file_rules().size(), 1u); |
| 827 ASSERT_EQ(c.bundle_data().file_rules()[0].sources().size(), 1u); |
| 828 } |
OLD | NEW |