| 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 // | |
| 5 // A tool making it easier to create IDs for unit testing. | |
| 6 | 4 |
| 7 #ifndef COMPONENTS_SYNC_TEST_ENGINE_TEST_ID_FACTORY_H_ | 5 #ifndef COMPONENTS_SYNC_TEST_ENGINE_TEST_ID_FACTORY_H_ |
| 8 #define COMPONENTS_SYNC_TEST_ENGINE_TEST_ID_FACTORY_H_ | 6 #define COMPONENTS_SYNC_TEST_ENGINE_TEST_ID_FACTORY_H_ |
| 9 | 7 |
| 10 #include <stdint.h> | 8 #include <stdint.h> |
| 11 | 9 |
| 12 #include <string> | 10 #include <string> |
| 13 | 11 |
| 14 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
| 15 #include "components/sync/syncable/syncable_id.h" | 13 #include "components/sync/syncable/syncable_id.h" |
| 16 | 14 |
| 17 namespace syncer { | 15 namespace syncer { |
| 18 | 16 |
| 17 // A tool making it easier to create IDs for unit testing. |
| 19 class TestIdFactory { | 18 class TestIdFactory { |
| 20 public: | 19 public: |
| 21 TestIdFactory() : next_value_(1337000) {} | 20 TestIdFactory() : next_value_(1337000) {} |
| 22 ~TestIdFactory() {} | 21 ~TestIdFactory() {} |
| 23 | 22 |
| 24 // Get the root ID. | 23 // Get the root ID. |
| 25 static syncable::Id root() { return syncable::Id::GetRoot(); } | 24 static syncable::Id root() { return syncable::Id::GetRoot(); } |
| 26 | 25 |
| 27 // Make an ID from a number. If the number is zero, return the root ID. | 26 // Make an ID from a number. If the number is zero, return the root ID. |
| 28 // If the number is positive, create a server ID based on the value. If | 27 // If the number is positive, create a server ID based on the value. If |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 } | 59 } |
| 61 | 60 |
| 62 private: | 61 private: |
| 63 int next_value() { return next_value_++; } | 62 int next_value() { return next_value_++; } |
| 64 int next_value_; | 63 int next_value_; |
| 65 }; | 64 }; |
| 66 | 65 |
| 67 } // namespace syncer | 66 } // namespace syncer |
| 68 | 67 |
| 69 #endif // COMPONENTS_SYNC_TEST_ENGINE_TEST_ID_FACTORY_H_ | 68 #endif // COMPONENTS_SYNC_TEST_ENGINE_TEST_ID_FACTORY_H_ |
| OLD | NEW |