blob: 0a854feda8ede925e6bf79d9a480beb0f7b56711 [file] [log] [blame]
// Copyright 2018 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_MODULAR_LIB_TESTING_TEST_STORY_COMMAND_EXECUTOR_H_
#define SRC_MODULAR_LIB_TESTING_TEST_STORY_COMMAND_EXECUTOR_H_
#include <fuchsia/modular/cpp/fidl.h>
#include <vector>
#include "src/modular/bin/sessionmgr/puppet_master/story_command_executor.h"
#include "src/modular/bin/sessionmgr/storage/story_storage.h"
namespace modular_testing {
class TestStoryCommandExecutor : public modular::StoryCommandExecutor {
public:
// Optional. If a |StoryStorage| is set, certain executed commands perform limited (as-needed to
// support existing test cases) updates to the |StoryStorage|. See ExecuteCommandsInternal().
void SetStoryStorage(std::shared_ptr<modular::StoryStorage> story_storage);
// Change the default return status and optional error message to be returned from
// |StoryController|->Execute()
void SetExecuteReturnResult(fuchsia::modular::ExecuteStatus status,
fidl::StringPtr error_message);
// Reset execute_count to 0, and clear the last_story_id and last_commands vector.
void Reset();
int execute_count() const { return execute_count_; }
fidl::StringPtr last_story_id() const { return last_story_id_; }
const std::vector<fuchsia::modular::StoryCommand>& last_commands() const {
return last_commands_;
}
private:
// |StoryCommandExecutor|
void ExecuteCommandsInternal(fidl::StringPtr story_id,
std::vector<fuchsia::modular::StoryCommand> commands,
fit::function<void(fuchsia::modular::ExecuteResult)> done) override;
int execute_count_{0};
fidl::StringPtr last_story_id_;
std::vector<fuchsia::modular::StoryCommand> last_commands_;
fuchsia::modular::ExecuteResult result_;
std::shared_ptr<modular::StoryStorage> story_storage_;
};
} // namespace modular_testing
#endif // SRC_MODULAR_LIB_TESTING_TEST_STORY_COMMAND_EXECUTOR_H_