Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(569)

Unified Diff: components/undo/undo_manager_test.cc

Issue 2644203003: Remove ScopedVector in //component/undo (Closed)
Patch Set: Remove ScopedVector in //component/undo Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/undo/undo_manager.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/undo/undo_manager_test.cc
diff --git a/components/undo/undo_manager_test.cc b/components/undo/undo_manager_test.cc
index eea15985faba36256d53fbfd6007254b66cda3fb..03dc138b711cfcdcd52ff85609b688d3f1513609 100644
--- a/components/undo/undo_manager_test.cc
+++ b/components/undo/undo_manager_test.cc
@@ -13,6 +13,53 @@
namespace {
+std::vector<UndoOperation*> ConvertToRawPtrVector(
+ const std::vector<std::unique_ptr<UndoOperation>>& args) {
+ std::vector<UndoOperation*> args_rawptrs;
+ for (auto i = args.begin(); i != args.end(); ++i)
+ args_rawptrs.push_back(i->get());
+ return args_rawptrs;
+}
+
+} // namespace
+
+// UndoManagerTestApi ----------------------------------------------------------
+
+class UndoManagerTestApi {
+ public:
+ // Returns all UndoOperations that are awaiting Undo or Redo.
+ static std::vector<UndoOperation*> GetAllUndoOperations(
+ const UndoManager& undo_manager);
+};
sky 2017/01/24 18:15:52 private: DISALLOW_IMPLICIT_CONSTRUCTORS
ke.he 2017/01/25 15:03:51 Done.
+
+std::vector<UndoOperation*> UndoManagerTestApi::GetAllUndoOperations(
+ const UndoManager& undo_manager) {
+ std::vector<UndoOperation*> result;
+ for (size_t i = 0; i < undo_manager.undo_actions_.size(); ++i) {
+ const std::vector<UndoOperation*> operations =
+ ConvertToRawPtrVector(undo_manager.undo_actions_[i]->undo_operations());
+ result.insert(result.end(), operations.begin(), operations.end());
+ }
+ for (size_t i = 0; i < undo_manager.redo_actions_.size(); ++i) {
+ const std::vector<UndoOperation*> operations =
+ ConvertToRawPtrVector(undo_manager.redo_actions_[i]->undo_operations());
+ result.insert(result.end(), operations.begin(), operations.end());
+ }
+ // Ensure that if an Undo is in progress the UndoOperations part of that
+ // UndoGroup are included in the returned set. This will ensure that any
+ // changes (such as renumbering) will be applied to any potentially
+ // unprocessed UndoOperations.
+ if (undo_manager.undo_in_progress_action_) {
+ const std::vector<UndoOperation*> operations = ConvertToRawPtrVector(
+ undo_manager.undo_in_progress_action_->undo_operations());
+ result.insert(result.end(), operations.begin(), operations.end());
+ }
+
+ return result;
+}
+
+namespace {
+
class TestUndoOperation;
// TestUndoService -------------------------------------------------------------
@@ -231,7 +278,7 @@ TEST(UndoServiceTest, GetAllUndoOperations) {
ASSERT_EQ(1U, undo_service.undo_manager_.redo_count());
std::vector<UndoOperation*> all_operations =
- undo_service.undo_manager_.GetAllUndoOperations();
+ UndoManagerTestApi::GetAllUndoOperations(undo_service.undo_manager_);
EXPECT_EQ(4U, all_operations.size());
}
« no previous file with comments | « components/undo/undo_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698