59 lines
1.2 KiB
C++
59 lines
1.2 KiB
C++
#include "../src/page.h"
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
struct LifecycleEvent {
|
|
std::string type;
|
|
int pageId;
|
|
|
|
bool operator==(const LifecycleEvent& other) const
|
|
{
|
|
return type == other.type && pageId == other.pageId;
|
|
}
|
|
bool operator!=(const LifecycleEvent& other) const
|
|
{
|
|
return !(*this == other);
|
|
}
|
|
};
|
|
|
|
inline std::vector<LifecycleEvent>& lifecycle_log()
|
|
{
|
|
static std::vector<LifecycleEvent> log;
|
|
return log;
|
|
}
|
|
|
|
inline void clear_log()
|
|
{
|
|
lifecycle_log().clear();
|
|
}
|
|
|
|
class TestPage : public Page {
|
|
public:
|
|
explicit TestPage(int id) : id_(id) {}
|
|
|
|
int id() const { return id_; }
|
|
|
|
void onPush(AppState& state) override
|
|
{
|
|
lifecycle_log().push_back({"onPush", id_});
|
|
}
|
|
void onResume(AppState& state) override
|
|
{
|
|
lifecycle_log().push_back({"onResume", id_});
|
|
}
|
|
void onPause(AppState& state) override
|
|
{
|
|
lifecycle_log().push_back({"onPause", id_});
|
|
}
|
|
void onPop(AppState& state) override
|
|
{
|
|
lifecycle_log().push_back({"onPop", id_});
|
|
}
|
|
void handleEvent(const SDL_Event& event) override {}
|
|
void update(float dt) override {}
|
|
void render(SDL_Renderer* renderer) override {}
|
|
|
|
private:
|
|
int id_;
|
|
};
|