| 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 21 matching lines...) Expand all Loading... |
| 32 }; | 32 }; |
| 33 | 33 |
| 34 // TestUndoOperation ----------------------------------------------------------- | 34 // TestUndoOperation ----------------------------------------------------------- |
| 35 | 35 |
| 36 class TestUndoOperation : public UndoOperation { | 36 class TestUndoOperation : public UndoOperation { |
| 37 public: | 37 public: |
| 38 explicit TestUndoOperation(TestUndoService* undo_service); | 38 explicit TestUndoOperation(TestUndoService* undo_service); |
| 39 virtual ~TestUndoOperation(); | 39 virtual ~TestUndoOperation(); |
| 40 | 40 |
| 41 // UndoOperation: | 41 // UndoOperation: |
| 42 virtual void Undo() OVERRIDE; | 42 virtual void Undo() override; |
| 43 virtual int GetUndoLabelId() const OVERRIDE; | 43 virtual int GetUndoLabelId() const override; |
| 44 virtual int GetRedoLabelId() const OVERRIDE; | 44 virtual int GetRedoLabelId() const override; |
| 45 | 45 |
| 46 private: | 46 private: |
| 47 TestUndoService* undo_service_; | 47 TestUndoService* undo_service_; |
| 48 | 48 |
| 49 DISALLOW_COPY_AND_ASSIGN(TestUndoOperation); | 49 DISALLOW_COPY_AND_ASSIGN(TestUndoOperation); |
| 50 }; | 50 }; |
| 51 | 51 |
| 52 TestUndoOperation::TestUndoOperation(TestUndoService* undo_service) | 52 TestUndoOperation::TestUndoOperation(TestUndoService* undo_service) |
| 53 : undo_service_(undo_service) { | 53 : undo_service_(undo_service) { |
| 54 } | 54 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 } | 97 } |
| 98 | 98 |
| 99 // TestObserver ---------------------------------------------------------------- | 99 // TestObserver ---------------------------------------------------------------- |
| 100 | 100 |
| 101 class TestObserver : public UndoManagerObserver { | 101 class TestObserver : public UndoManagerObserver { |
| 102 public: | 102 public: |
| 103 TestObserver() : state_change_count_(0) {} | 103 TestObserver() : state_change_count_(0) {} |
| 104 // Returns the number of state change callbacks | 104 // Returns the number of state change callbacks |
| 105 int state_change_count() { return state_change_count_; } | 105 int state_change_count() { return state_change_count_; } |
| 106 | 106 |
| 107 virtual void OnUndoManagerStateChange() OVERRIDE { ++state_change_count_; } | 107 virtual void OnUndoManagerStateChange() override { ++state_change_count_; } |
| 108 | 108 |
| 109 private: | 109 private: |
| 110 int state_change_count_; | 110 int state_change_count_; |
| 111 | 111 |
| 112 DISALLOW_COPY_AND_ASSIGN(TestObserver); | 112 DISALLOW_COPY_AND_ASSIGN(TestObserver); |
| 113 }; | 113 }; |
| 114 | 114 |
| 115 // Tests ----------------------------------------------------------------------- | 115 // Tests ----------------------------------------------------------------------- |
| 116 | 116 |
| 117 TEST(UndoServiceTest, AddUndoActions) { | 117 TEST(UndoServiceTest, AddUndoActions) { |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 undo_service.undo_manager_.Redo(); | 257 undo_service.undo_manager_.Redo(); |
| 258 int callback_count_after_redo = observer.state_change_count(); | 258 int callback_count_after_redo = observer.state_change_count(); |
| 259 EXPECT_GT(callback_count_after_redo, callback_count_after_undo); | 259 EXPECT_GT(callback_count_after_redo, callback_count_after_undo); |
| 260 | 260 |
| 261 undo_service.undo_manager_.RemoveObserver(&observer); | 261 undo_service.undo_manager_.RemoveObserver(&observer); |
| 262 undo_service.undo_manager_.Undo(); | 262 undo_service.undo_manager_.Undo(); |
| 263 EXPECT_EQ(callback_count_after_redo, observer.state_change_count()); | 263 EXPECT_EQ(callback_count_after_redo, observer.state_change_count()); |
| 264 } | 264 } |
| 265 | 265 |
| 266 } // namespace | 266 } // namespace |
| OLD | NEW |