Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(176)

Unified Diff: sync/test/engine/mock_model_type_worker.h

Issue 2130453004: [Sync] Move //sync to //components/sync. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sync/test/engine/mock_model_type_processor.cc ('k') | sync/test/engine/mock_model_type_worker.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/test/engine/mock_model_type_worker.h
diff --git a/sync/test/engine/mock_model_type_worker.h b/sync/test/engine/mock_model_type_worker.h
deleted file mode 100644
index b8499cf07ecec3b4dcdf8e392ef34ed7b3b99423..0000000000000000000000000000000000000000
--- a/sync/test/engine/mock_model_type_worker.h
+++ /dev/null
@@ -1,123 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef SYNC_TEST_ENGINE_MOCK_MODEL_TYPE_WORKER_H_
-#define SYNC_TEST_ENGINE_MOCK_MODEL_TYPE_WORKER_H_
-
-#include <stddef.h>
-#include <stdint.h>
-
-#include <deque>
-#include <map>
-#include <string>
-#include <vector>
-
-#include "base/macros.h"
-#include "sync/engine/commit_queue.h"
-#include "sync/internal_api/public/model_type_processor.h"
-#include "sync/internal_api/public/non_blocking_sync_common.h"
-#include "sync/protocol/data_type_state.pb.h"
-
-namespace syncer_v2 {
-
-// Receives and records commit requests sent through the ModelTypeWorker.
-//
-// This class also includes features intended to help mock out server behavior.
-// It has some basic functionality to keep track of server state and generate
-// plausible UpdateResponseData and CommitResponseData messages.
-class MockModelTypeWorker : public CommitQueue {
- public:
- MockModelTypeWorker(const sync_pb::DataTypeState& data_type_state,
- ModelTypeProcessor* processor);
- ~MockModelTypeWorker() override;
-
- // Implementation of ModelTypeWorker.
- void EnqueueForCommit(const CommitRequestDataList& list) override;
-
- // Getters to inspect the requests sent to this object.
- size_t GetNumPendingCommits() const;
- CommitRequestDataList GetNthPendingCommit(size_t n) const;
- bool HasPendingCommitForTag(const std::string& tag) const;
- CommitRequestData GetLatestPendingCommitForTag(const std::string& tag) const;
-
- // Expect that the |n|th commit request list has one commit request for |tag|
- // with |value| set.
- void ExpectNthPendingCommit(size_t n,
- const std::string& tag,
- const std::string& value);
-
- // For each tag in |tags|, expect a corresponding request list of length one.
- void ExpectPendingCommits(const std::vector<std::string>& tags);
-
- // Trigger an update from the server containing a single entity. See
- // GenerateUpdateData for parameter descriptions. |version_offset| defaults to
- // 1 and |ekn| defaults to the current encryption key name the worker has.
- void UpdateFromServer(const std::string& tag, const std::string& value);
- void UpdateFromServer(const std::string& tag,
- const std::string& value,
- int64_t version_offset);
- void UpdateFromServer(const std::string& tag,
- const std::string& value,
- int64_t version_offset,
- const std::string& ekn);
-
- // Returns an UpdateResponseData representing an update received from
- // the server. Updates server state accordingly. |tag| is used to generate the
- // tag hash and the specifics along with |value|.
- //
- // The |version_offset| field can be used to emulate stale data (ie. versions
- // going backwards), reflections and redeliveries (ie. several instances of
- // the same version) or new updates.
- //
- // |ekn| is the encryption key name this item will fake having.
- UpdateResponseData GenerateUpdateData(const std::string& tag,
- const std::string& value,
- int64_t version_offset,
- const std::string& ekn);
-
- // Triggers a server-side deletion of the entity with |tag|; updates server
- // state accordingly.
- void TombstoneFromServer(const std::string& tag);
-
- // Pops one pending commit from the front of the queue and send a commit
- // response to the processor for it.
- void AckOnePendingCommit();
-
- // Set the encryption key to |ekn| and inform the processor with an update
- // containing the data in |update|, which defaults to an empty list.
- void UpdateWithEncryptionKey(const std::string& ekn);
- void UpdateWithEncryptionKey(const std::string& ekn,
- const UpdateResponseDataList& update);
-
- private:
- // Generate an ID string.
- static std::string GenerateId(const std::string& tag_hash);
-
- // Returns a commit response that indicates a successful commit of the
- // given |request_data|. Updates server state accordingly.
- CommitResponseData SuccessfulCommitResponse(
- const CommitRequestData& request_data);
-
- // Retrieve or set the server version.
- int64_t GetServerVersion(const std::string& tag_hash);
- void SetServerVersion(const std::string& tag_hash, int64_t version);
-
- sync_pb::DataTypeState data_type_state_;
-
- // A pointer to the processor for this mock worker.
- ModelTypeProcessor* processor_;
-
- // A record of past commits requests.
- std::deque<CommitRequestDataList> pending_commits_;
-
- // Map of versions by client tag.
- // This is an essential part of the mocked server state.
- std::map<const std::string, int64_t> server_versions_;
-
- DISALLOW_COPY_AND_ASSIGN(MockModelTypeWorker);
-};
-
-} // namespace syncer_v2
-
-#endif // SYNC_TEST_ENGINE_MOCK_MODEL_TYPE_WORKER_H_
« no previous file with comments | « sync/test/engine/mock_model_type_processor.cc ('k') | sync/test/engine/mock_model_type_worker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698