#include "app_core/document_platform_io.h"
#include "test_harness.h"

namespace {

void picked_path_ignores_empty_path(pp::tests::Harness& harness)
{
    PP_EXPECT(
        harness,
        pp::app::plan_picked_path("") == pp::app::PickedPathAction::ignore_empty_path);
}

void picked_path_invokes_callback_for_nonempty_path(pp::tests::Harness& harness)
{
    PP_EXPECT(
        harness,
        pp::app::plan_picked_path("D:/Paint/demo.ppi") == pp::app::PickedPathAction::invoke_callback);
}

void display_file_ignores_empty_path(pp::tests::Harness& harness)
{
    PP_EXPECT(
        harness,
        pp::app::plan_display_file("") == pp::app::DisplayFileAction::ignore_empty_path);
}

void display_file_opens_nonempty_path(pp::tests::Harness& harness)
{
    PP_EXPECT(
        harness,
        pp::app::plan_display_file("D:/Paint/export.png") == pp::app::DisplayFileAction::open_external_file);
}

void virtual_keyboard_plans_show_action(pp::tests::Harness& harness)
{
    PP_EXPECT(
        harness,
        pp::app::plan_virtual_keyboard(true) == pp::app::VirtualKeyboardAction::show_keyboard);
}

void virtual_keyboard_plans_hide_action(pp::tests::Harness& harness)
{
    PP_EXPECT(
        harness,
        pp::app::plan_virtual_keyboard(false) == pp::app::VirtualKeyboardAction::hide_keyboard);
}

void cursor_visibility_plans_show_action(pp::tests::Harness& harness)
{
    PP_EXPECT(
        harness,
        pp::app::plan_cursor_visibility(true) == pp::app::CursorVisibilityAction::show_cursor);
}

void cursor_visibility_plans_hide_action(pp::tests::Harness& harness)
{
    PP_EXPECT(
        harness,
        pp::app::plan_cursor_visibility(false) == pp::app::CursorVisibilityAction::hide_cursor);
}

void clipboard_read_plans_text_read(pp::tests::Harness& harness)
{
    PP_EXPECT(
        harness,
        pp::app::plan_clipboard_read() == pp::app::ClipboardReadAction::read_text);
}

void clipboard_write_plans_text_write(pp::tests::Harness& harness)
{
    PP_EXPECT(
        harness,
        pp::app::plan_clipboard_write("#ff00aa") == pp::app::ClipboardWriteAction::write_text);
}

void clipboard_write_keeps_empty_text_writable(pp::tests::Harness& harness)
{
    PP_EXPECT(
        harness,
        pp::app::plan_clipboard_write("") == pp::app::ClipboardWriteAction::write_text);
}

}

int main()
{
    pp::tests::Harness harness;
    harness.run("picked path ignores empty path", picked_path_ignores_empty_path);
    harness.run("picked path invokes callback for nonempty path", picked_path_invokes_callback_for_nonempty_path);
    harness.run("display file ignores empty path", display_file_ignores_empty_path);
    harness.run("display file opens nonempty path", display_file_opens_nonempty_path);
    harness.run("virtual keyboard plans show action", virtual_keyboard_plans_show_action);
    harness.run("virtual keyboard plans hide action", virtual_keyboard_plans_hide_action);
    harness.run("cursor visibility plans show action", cursor_visibility_plans_show_action);
    harness.run("cursor visibility plans hide action", cursor_visibility_plans_hide_action);
    harness.run("clipboard read plans text read", clipboard_read_plans_text_read);
    harness.run("clipboard write plans text write", clipboard_write_plans_text_write);
    harness.run("clipboard write keeps empty text writable", clipboard_write_keeps_empty_text_writable);
    return harness.finish();
}
