| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "base/auto_reset.h" | 5 #include "base/auto_reset.h" |
| 6 #include "chrome/browser/undo/undo_manager.h" | 6 #include "chrome/browser/undo/undo_manager.h" |
| 7 #include "chrome/browser/undo/undo_manager_observer.h" | 7 #include "chrome/browser/undo/undo_manager_observer.h" |
| 8 #include "chrome/browser/undo/undo_operation.h" | 8 #include "chrome/browser/undo/undo_operation.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 | 78 |
| 79 TestUndoService::~TestUndoService() { | 79 TestUndoService::~TestUndoService() { |
| 80 } | 80 } |
| 81 | 81 |
| 82 void TestUndoService::Redo() { | 82 void TestUndoService::Redo() { |
| 83 base::AutoReset<bool> incoming_changes(&performing_redo_, true); | 83 base::AutoReset<bool> incoming_changes(&performing_redo_, true); |
| 84 undo_manager_.Redo(); | 84 undo_manager_.Redo(); |
| 85 } | 85 } |
| 86 | 86 |
| 87 void TestUndoService::TriggerOperation() { | 87 void TestUndoService::TriggerOperation() { |
| 88 scoped_ptr<TestUndoOperation> op(new TestUndoOperation(this)); | 88 undo_manager_.AddUndoOperation(make_scoped_ptr(new TestUndoOperation(this))); |
| 89 undo_manager_.AddUndoOperation(op.PassAs<UndoOperation>()); | |
| 90 } | 89 } |
| 91 | 90 |
| 92 void TestUndoService::RecordUndoCall() { | 91 void TestUndoService::RecordUndoCall() { |
| 93 if (performing_redo_) | 92 if (performing_redo_) |
| 94 ++redo_operation_count_; | 93 ++redo_operation_count_; |
| 95 else | 94 else |
| 96 ++undo_operation_count_; | 95 ++undo_operation_count_; |
| 97 } | 96 } |
| 98 | 97 |
| 99 // TestObserver ---------------------------------------------------------------- | 98 // TestObserver ---------------------------------------------------------------- |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 undo_service.undo_manager_.Redo(); | 256 undo_service.undo_manager_.Redo(); |
| 258 int callback_count_after_redo = observer.state_change_count(); | 257 int callback_count_after_redo = observer.state_change_count(); |
| 259 EXPECT_GT(callback_count_after_redo, callback_count_after_undo); | 258 EXPECT_GT(callback_count_after_redo, callback_count_after_undo); |
| 260 | 259 |
| 261 undo_service.undo_manager_.RemoveObserver(&observer); | 260 undo_service.undo_manager_.RemoveObserver(&observer); |
| 262 undo_service.undo_manager_.Undo(); | 261 undo_service.undo_manager_.Undo(); |
| 263 EXPECT_EQ(callback_count_after_redo, observer.state_change_count()); | 262 EXPECT_EQ(callback_count_after_redo, observer.state_change_count()); |
| 264 } | 263 } |
| 265 | 264 |
| 266 } // namespace | 265 } // namespace |
| OLD | NEW |