OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "testing/gmock/include/gmock/gmock.h" | 5 #include "testing/gmock/include/gmock/gmock.h" |
6 #include "testing/gtest/include/gtest/gtest.h" | 6 #include "testing/gtest/include/gtest/gtest.h" |
7 | 7 |
8 #include "chrome/browser/sync/glue/fake_data_type_controller.h" | 8 #include "chrome/browser/sync/glue/fake_data_type_controller.h" |
9 | 9 |
10 #include "testing/gmock/include/gmock/gmock.h" | 10 #include "testing/gmock/include/gmock/gmock.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 state_ = NOT_RUNNING; | 67 state_ = NOT_RUNNING; |
68 error.Reset(FROM_HERE, "Fake error", type_); | 68 error.Reset(FROM_HERE, "Fake error", type_); |
69 } | 69 } |
70 last_start_callback_.Run(result, error); | 70 last_start_callback_.Run(result, error); |
71 last_start_callback_.Reset(); | 71 last_start_callback_.Reset(); |
72 } | 72 } |
73 | 73 |
74 // * -> NOT_RUNNING | 74 // * -> NOT_RUNNING |
75 void FakeDataTypeController::Stop() { | 75 void FakeDataTypeController::Stop() { |
76 state_ = NOT_RUNNING; | 76 state_ = NOT_RUNNING; |
| 77 if (!model_load_callback_.is_null()) { |
| 78 // Real data type controllers run the callback and specify "ABORTED" as an |
| 79 // error. We should probably find a way to use the real code and mock out |
| 80 // unnecessary pieces. |
| 81 SimulateModelLoadFinishing(); |
| 82 } |
| 83 |
77 // The DTM still expects |last_start_callback_| to be called back. | 84 // The DTM still expects |last_start_callback_| to be called back. |
78 if (!last_start_callback_.is_null()) { | 85 if (!last_start_callback_.is_null()) { |
79 SyncError error(FROM_HERE, "Fake error", type_); | 86 SyncError error(FROM_HERE, "Fake error", type_); |
80 last_start_callback_.Run(ABORTED, error); | 87 last_start_callback_.Run(ABORTED, error); |
81 } | 88 } |
82 } | 89 } |
83 | 90 |
84 ModelType FakeDataTypeController::type() const { | 91 ModelType FakeDataTypeController::type() const { |
85 return type_; | 92 return type_; |
86 } | 93 } |
(...skipping 27 matching lines...) Expand all Loading... |
114 void FakeDataTypeController::SetDelayModelLoad() { | 121 void FakeDataTypeController::SetDelayModelLoad() { |
115 model_load_delayed_ = true; | 122 model_load_delayed_ = true; |
116 } | 123 } |
117 | 124 |
118 void FakeDataTypeController::SimulateModelLoadFinishing() { | 125 void FakeDataTypeController::SimulateModelLoadFinishing() { |
119 ModelLoadCallback model_load_callback = model_load_callback_; | 126 ModelLoadCallback model_load_callback = model_load_callback_; |
120 model_load_callback.Run(type(), SyncError()); | 127 model_load_callback.Run(type(), SyncError()); |
121 } | 128 } |
122 | 129 |
123 } // namespace browser_sync | 130 } // namespace browser_sync |
OLD | NEW |