session_sync_test_helper.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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
  3. // found in the LICENSE file.
  4. #ifndef COMPONENTS_SYNC_SESSIONS_SESSION_SYNC_TEST_HELPER_H_
  5. #define COMPONENTS_SYNC_SESSIONS_SESSION_SYNC_TEST_HELPER_H_
  6. #include <string>
  7. #include <vector>
  8. #include "components/sessions/core/session_id.h"
  9. namespace sync_pb {
  10. class SessionSpecifics;
  11. }
  12. namespace sync_sessions {
  13. struct SyncedSession;
  14. class SessionSyncTestHelper {
  15. public:
  16. SessionSyncTestHelper() : max_tab_node_id_(0) {}
  17. SessionSyncTestHelper(const SessionSyncTestHelper&) = delete;
  18. SessionSyncTestHelper& operator=(const SessionSyncTestHelper&) = delete;
  19. static void BuildSessionSpecifics(const std::string& tag,
  20. sync_pb::SessionSpecifics* meta);
  21. static void AddWindowSpecifics(SessionID window_id,
  22. const std::vector<SessionID>& tab_list,
  23. sync_pb::SessionSpecifics* meta);
  24. static void VerifySyncedSession(
  25. const std::string& tag,
  26. const std::vector<std::vector<SessionID>>& windows,
  27. const SyncedSession& session);
  28. // Build a SessionSpecifics object with a tab and sample data. Uses a
  29. // monotonically increasing variable to generate tab_node_ids and avoid
  30. // conflicts.
  31. sync_pb::SessionSpecifics BuildTabSpecifics(const std::string& tag,
  32. SessionID window_id,
  33. SessionID tab_id);
  34. // Overload of BuildTabSpecifics to allow forcing a specific tab_node_id.
  35. // Typically only useful to test reusing tab_node_ids.
  36. sync_pb::SessionSpecifics BuildTabSpecifics(const std::string& tag,
  37. SessionID window_id,
  38. SessionID tab_id,
  39. int tab_node_id);
  40. sync_pb::SessionSpecifics BuildForeignSession(
  41. const std::string& tag,
  42. const std::vector<SessionID>& tab_list,
  43. std::vector<sync_pb::SessionSpecifics>* tabs);
  44. void Reset();
  45. private:
  46. int max_tab_node_id_;
  47. };
  48. } // namespace sync_sessions
  49. #endif // COMPONENTS_SYNC_SESSIONS_SESSION_SYNC_TEST_HELPER_H_