| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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/visual_studio_writer.h" | 5 #include "tools/gn/visual_studio_writer.h" |
| 6 | 6 |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 #include "tools/gn/test_with_scope.h" | 8 #include "tools/gn/test_with_scope.h" |
| 9 #include "tools/gn/visual_studio_utils.h" | 9 #include "tools/gn/visual_studio_utils.h" |
| 10 | 10 |
| 11 namespace { | 11 namespace { |
| 12 | 12 |
| 13 class VisualStudioWriterTest : public testing::Test { | 13 class VisualStudioWriterTest : public testing::Test { |
| 14 protected: | 14 protected: |
| 15 TestWithScope setup_; | 15 TestWithScope setup_; |
| 16 }; | 16 }; |
| 17 | 17 |
| 18 std::string MakeTestPath(const std::string& path) { | 18 std::string MakeTestPath(const std::string& path) { |
| 19 #if defined(OS_WIN) | 19 #if defined(OS_WIN) |
| 20 return "C:" + path; | 20 return "C:" + path; |
| 21 #else | 21 #else |
| 22 return path; | 22 return path; |
| 23 #endif | 23 #endif |
| 24 } | 24 } |
| 25 | 25 |
| 26 } // namespace | 26 } // namespace |
| 27 | 27 |
| 28 TEST_F(VisualStudioWriterTest, ResolveSolutionFolders) { | 28 TEST_F(VisualStudioWriterTest, ResolveSolutionFolders) { |
| 29 VisualStudioWriter writer(setup_.build_settings(), true, "Win32", | 29 VisualStudioWriter writer(setup_.build_settings(), "Win32", |
| 30 VisualStudioWriter::Version::Vs2015); | 30 VisualStudioWriter::Version::Vs2015); |
| 31 | 31 |
| 32 std::string path = | 32 std::string path = |
| 33 MakeTestPath("/foo/chromium/src/out/Debug/obj/base/base.vcxproj"); | 33 MakeTestPath("/foo/chromium/src/out/Debug/obj/base/base.vcxproj"); |
| 34 writer.projects_.push_back(new VisualStudioWriter::SolutionProject( | 34 writer.projects_.push_back(new VisualStudioWriter::SolutionProject( |
| 35 "base", path, MakeGuid(path, "project"), | 35 "base", path, MakeGuid(path, "project"), |
| 36 MakeTestPath("/foo/chromium/src/base"), "Win32")); | 36 MakeTestPath("/foo/chromium/src/base"), "Win32")); |
| 37 | 37 |
| 38 path = MakeTestPath("/foo/chromium/src/out/Debug/obj/tools/gn/gn.vcxproj"); | 38 path = MakeTestPath("/foo/chromium/src/out/Debug/obj/tools/gn/gn.vcxproj"); |
| 39 writer.projects_.push_back(new VisualStudioWriter::SolutionProject( | 39 writer.projects_.push_back(new VisualStudioWriter::SolutionProject( |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 writer.folders_[3]->path); | 73 writer.folders_[3]->path); |
| 74 ASSERT_EQ(writer.folders_[2], writer.folders_[3]->parent_folder); | 74 ASSERT_EQ(writer.folders_[2], writer.folders_[3]->parent_folder); |
| 75 | 75 |
| 76 ASSERT_EQ(writer.folders_[0], writer.projects_[0]->parent_folder); | 76 ASSERT_EQ(writer.folders_[0], writer.projects_[0]->parent_folder); |
| 77 ASSERT_EQ(writer.folders_[3], writer.projects_[1]->parent_folder); | 77 ASSERT_EQ(writer.folders_[3], writer.projects_[1]->parent_folder); |
| 78 ASSERT_EQ(writer.folders_[1], writer.projects_[2]->parent_folder); | 78 ASSERT_EQ(writer.folders_[1], writer.projects_[2]->parent_folder); |
| 79 ASSERT_EQ(writer.folders_[0], writer.projects_[3]->parent_folder); | 79 ASSERT_EQ(writer.folders_[0], writer.projects_[3]->parent_folder); |
| 80 } | 80 } |
| 81 | 81 |
| 82 TEST_F(VisualStudioWriterTest, ResolveSolutionFolders_AbsPath) { | 82 TEST_F(VisualStudioWriterTest, ResolveSolutionFolders_AbsPath) { |
| 83 VisualStudioWriter writer(setup_.build_settings(), true, "Win32", | 83 VisualStudioWriter writer(setup_.build_settings(), "Win32", |
| 84 VisualStudioWriter::Version::Vs2015); | 84 VisualStudioWriter::Version::Vs2015); |
| 85 | 85 |
| 86 std::string path = | 86 std::string path = |
| 87 MakeTestPath("/foo/chromium/src/out/Debug/obj/base/base.vcxproj"); | 87 MakeTestPath("/foo/chromium/src/out/Debug/obj/base/base.vcxproj"); |
| 88 writer.projects_.push_back(new VisualStudioWriter::SolutionProject( | 88 writer.projects_.push_back(new VisualStudioWriter::SolutionProject( |
| 89 "base", path, MakeGuid(path, "project"), | 89 "base", path, MakeGuid(path, "project"), |
| 90 MakeTestPath("/foo/chromium/src/base"), "Win32")); | 90 MakeTestPath("/foo/chromium/src/base"), "Win32")); |
| 91 | 91 |
| 92 path = MakeTestPath("/foo/chromium/src/out/Debug/obj/tools/gn/gn.vcxproj"); | 92 path = MakeTestPath("/foo/chromium/src/out/Debug/obj/tools/gn/gn.vcxproj"); |
| 93 writer.projects_.push_back(new VisualStudioWriter::SolutionProject( | 93 writer.projects_.push_back(new VisualStudioWriter::SolutionProject( |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 ASSERT_EQ("gn", writer.folders_[6]->name); | 139 ASSERT_EQ("gn", writer.folders_[6]->name); |
| 140 ASSERT_EQ(MakeTestPath("/foo/chromium/src/tools/gn"), | 140 ASSERT_EQ(MakeTestPath("/foo/chromium/src/tools/gn"), |
| 141 writer.folders_[6]->path); | 141 writer.folders_[6]->path); |
| 142 ASSERT_EQ(writer.folders_[5], writer.folders_[6]->parent_folder); | 142 ASSERT_EQ(writer.folders_[5], writer.folders_[6]->parent_folder); |
| 143 | 143 |
| 144 ASSERT_EQ(writer.folders_[4], writer.projects_[0]->parent_folder); | 144 ASSERT_EQ(writer.folders_[4], writer.projects_[0]->parent_folder); |
| 145 ASSERT_EQ(writer.folders_[6], writer.projects_[1]->parent_folder); | 145 ASSERT_EQ(writer.folders_[6], writer.projects_[1]->parent_folder); |
| 146 ASSERT_EQ(writer.folders_[0], writer.projects_[2]->parent_folder); | 146 ASSERT_EQ(writer.folders_[0], writer.projects_[2]->parent_folder); |
| 147 ASSERT_EQ(writer.folders_[1], writer.projects_[3]->parent_folder); | 147 ASSERT_EQ(writer.folders_[1], writer.projects_[3]->parent_folder); |
| 148 } | 148 } |
| OLD | NEW |