| 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 <map> | 5 #include <map> |
| 6 #include <utility> | 6 #include <utility> |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/memory/linked_ptr.h" | 10 #include "base/memory/linked_ptr.h" |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 bool MockInputFileManager::HasTwoPending(const SourceFile& f1, | 93 bool MockInputFileManager::HasTwoPending(const SourceFile& f1, |
| 94 const SourceFile& f2) const { | 94 const SourceFile& f2) const { |
| 95 if (pending_.size() != 2u) | 95 if (pending_.size() != 2u) |
| 96 return false; | 96 return false; |
| 97 return pending_[0].first == f1 && pending_[1].first == f2; | 97 return pending_[0].first == f1 && pending_[1].first == f2; |
| 98 } | 98 } |
| 99 | 99 |
| 100 void MockInputFileManager::IssueAllPending() { | 100 void MockInputFileManager::IssueAllPending() { |
| 101 BlockNode block(false); // Default response. | 101 BlockNode block(false); // Default response. |
| 102 | 102 |
| 103 for (size_t i = 0; i < pending_.size(); i++) { | 103 for (const auto& cur : pending_) { |
| 104 CannedResponseMap::const_iterator found = | 104 CannedResponseMap::const_iterator found = canned_responses_.find(cur.first); |
| 105 canned_responses_.find(pending_[i].first); | |
| 106 if (found == canned_responses_.end()) | 105 if (found == canned_responses_.end()) |
| 107 pending_[i].second.Run(&block); | 106 cur.second.Run(&block); |
| 108 else | 107 else |
| 109 pending_[i].second.Run(found->second->root.get()); | 108 cur.second.Run(found->second->root.get()); |
| 110 } | 109 } |
| 111 pending_.clear(); | 110 pending_.clear(); |
| 112 } | 111 } |
| 113 | 112 |
| 114 // LoaderTest ------------------------------------------------------------------ | 113 // LoaderTest ------------------------------------------------------------------ |
| 115 | 114 |
| 116 class LoaderTest : public testing::Test { | 115 class LoaderTest : public testing::Test { |
| 117 public: | 116 public: |
| 118 LoaderTest() { | 117 LoaderTest() { |
| 119 build_settings_.SetBuildDir(SourceDir("//out/Debug/")); | 118 build_settings_.SetBuildDir(SourceDir("//out/Debug/")); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 loader->Load(third_file, LocationRange(), second_tc); | 181 loader->Load(third_file, LocationRange(), second_tc); |
| 183 EXPECT_TRUE(mock_ifm_.HasOnePending(build_config)); | 182 EXPECT_TRUE(mock_ifm_.HasOnePending(build_config)); |
| 184 | 183 |
| 185 // Running the build config file should make our third file pending. | 184 // Running the build config file should make our third file pending. |
| 186 mock_ifm_.IssueAllPending(); | 185 mock_ifm_.IssueAllPending(); |
| 187 scheduler_.main_loop()->RunUntilIdle(); | 186 scheduler_.main_loop()->RunUntilIdle(); |
| 188 EXPECT_TRUE(mock_ifm_.HasTwoPending(second_file, third_file)); | 187 EXPECT_TRUE(mock_ifm_.HasTwoPending(second_file, third_file)); |
| 189 | 188 |
| 190 EXPECT_FALSE(scheduler_.is_failed()); | 189 EXPECT_FALSE(scheduler_.is_failed()); |
| 191 } | 190 } |
| OLD | NEW |