OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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. |
| 4 |
| 5 #include "tools/gn/ninja_bundle_data_target_writer.h" |
| 6 |
| 7 #include <algorithm> |
| 8 #include <sstream> |
| 9 |
| 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 #include "tools/gn/target.h" |
| 12 #include "tools/gn/test_with_scope.h" |
| 13 |
| 14 TEST(NinjaBundleDataTargetWriter, Run) { |
| 15 Err err; |
| 16 |
| 17 TestWithScope setup; |
| 18 setup.build_settings()->SetBuildDir(SourceDir("//out/Debug/")); |
| 19 |
| 20 Target bundle_data(setup.settings(), Label(SourceDir("//foo/"), "data")); |
| 21 bundle_data.set_output_type(Target::BUNDLE_DATA); |
| 22 bundle_data.sources().push_back(SourceFile("//foo/input1.txt")); |
| 23 bundle_data.sources().push_back(SourceFile("//foo/input2.txt")); |
| 24 bundle_data.sources().push_back( |
| 25 SourceFile("//foo/Foo.xcassets/Contents.json")); |
| 26 bundle_data.sources().push_back( |
| 27 SourceFile("//foo/Foo.xcassets/foo.imageset/Contents.json")); |
| 28 bundle_data.sources().push_back( |
| 29 SourceFile("//foo/Foo.xcassets/foo.imageset/FooIcon-29.png")); |
| 30 bundle_data.sources().push_back( |
| 31 SourceFile("//foo/Foo.xcassets/foo.imageset/FooIcon-29@2x.png")); |
| 32 bundle_data.sources().push_back( |
| 33 SourceFile("//foo/Foo.xcassets/foo.imageset/FooIcon-29@3x.png")); |
| 34 bundle_data.action_values().outputs() = SubstitutionList::MakeForTest( |
| 35 "{{bundle_resources_dir}}/{{source_file_part}}"); |
| 36 bundle_data.SetToolchain(setup.toolchain()); |
| 37 bundle_data.visibility().SetPublic(); |
| 38 ASSERT_TRUE(bundle_data.OnResolved(&err)); |
| 39 |
| 40 std::ostringstream out; |
| 41 NinjaBundleDataTargetWriter writer(&bundle_data, out); |
| 42 writer.Run(); |
| 43 |
| 44 const char expected[] = |
| 45 "build obj/foo/data.stamp: stamp " |
| 46 "../../foo/input1.txt " |
| 47 "../../foo/input2.txt " |
| 48 "../../foo/Foo.xcassets/Contents.json " |
| 49 "../../foo/Foo.xcassets/foo.imageset/Contents.json " |
| 50 "../../foo/Foo.xcassets/foo.imageset/FooIcon-29.png " |
| 51 "../../foo/Foo.xcassets/foo.imageset/FooIcon-29@2x.png " |
| 52 "../../foo/Foo.xcassets/foo.imageset/FooIcon-29@3x.png\n"; |
| 53 std::string out_str = out.str(); |
| 54 EXPECT_EQ(expected, out_str); |
| 55 } |
OLD | NEW |