| // Copyright 2019 The Fuchsia 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 SRC_DEVELOPER_FEEDBACK_CRASH_REPORTS_TESTS_STUB_CRASH_SERVER_H_ |
| #define SRC_DEVELOPER_FEEDBACK_CRASH_REPORTS_TESTS_STUB_CRASH_SERVER_H_ |
| |
| #include <map> |
| #include <string> |
| #include <vector> |
| |
| #include "src/developer/feedback/crash_reports/crash_server.h" |
| |
| namespace feedback { |
| |
| extern const char kStubCrashServerUrl[]; |
| extern const char kStubServerReportId[]; |
| |
| class StubCrashServer : public CrashServer { |
| public: |
| StubCrashServer(const std::vector<bool>& request_return_values) |
| : CrashServer(kStubCrashServerUrl), request_return_values_(request_return_values) { |
| next_return_value_ = request_return_values_.cbegin(); |
| } |
| |
| ~StubCrashServer(); |
| |
| bool MakeRequest(const std::map<std::string, std::string>& annotations, |
| const std::map<std::string, crashpad::FileReader*>& attachments, |
| std::string* server_report_id) override; |
| |
| // Whether the crash server expects at least one more call to MakeRequest(). |
| bool ExpectRequest() { return next_return_value_ != request_return_values_.cend(); } |
| |
| // Returns the annotations that were passed to the latest MakeRequest() call. |
| const std::map<std::string, std::string>& latest_annotations() { return latest_annotations_; } |
| |
| // Returns the keys for the attachments that were passed to the latest MakeRequest() call. |
| const std::vector<std::string>& latest_attachment_keys() { return latest_attachment_keys_; } |
| |
| private: |
| const std::vector<bool> request_return_values_; |
| std::vector<bool>::const_iterator next_return_value_; |
| |
| std::map<std::string, std::string> latest_annotations_; |
| std::vector<std::string> latest_attachment_keys_; |
| }; |
| |
| } // namespace feedback |
| |
| #endif // SRC_DEVELOPER_FEEDBACK_CRASH_REPORTS_TESTS_STUB_CRASH_SERVER_H_ |