Appium

 view release on metacpan or  search on metacpan

t/Appium.t  view on Meta::CPAN

                test => 'no args passes default strategy',
                key => 'strategy',
                value => 'tapOutside'
            }
        },
        {
            args => [ key_name => 'Done' ],
            expected => {
                test => 'can pass a key_name',
                key => 'keyName',
                value => 'Done'
            }
        },
        {
            args => [ strategy => 'fake strategy', key => 'Done' ],
            expected => {
                test => 'can pass a strategy',
                key => 'strategy',
                value => 'fake strategy'
            }
        }
    ];

    foreach (@$tests) {
        my $expected = $_->{expected};
        my (undef, $params) = $mock_appium->hide_keyboard(@{ $_->{args} });

        my $key = $expected->{key};
        ok( exists $params->{$key}, 'hide_keyboard, key: ' . $expected->{test});
        cmp_ok( $params->{$key}, 'eq', $expected->{value}, 'hide_keyboard, val: ' . $expected->{test});

        if ($expected->{test} eq 'can pass a strategy') {
            ok( exists $params->{key}, 'hide_keyboard, key: strategy and key are included');
            cmp_ok( $params->{key}, 'eq', 'Done', 'hide_keyboard, val: strategy and key are included');

        }
    }
}

ANDROID_KEYCODES: {
    my $code = 176;
    endpoint_ok('press_keycode', [ $code ], { keycode => $code });
    endpoint_ok('long_press_keycode', [ $code, 'metastate' ], { keycode => $code, metastate => 'metastate' });

}

PUSH_PULL: {
    my $path = '/fake/path';
    my $data = 'pretend to be base 64 encoded';
    endpoint_ok('pull_file', [ $path ], { path => $path });
    endpoint_ok('pull_folder', [ $path ], { path => $path });
    endpoint_ok('push_file', [ $path, $data ], { path => $path, data => $data });
}

FIND: {
    my @selector = qw/fake selection critera/;
    endpoint_ok('complex_find', [ @selector ], { selector => \@selector });
}

APP: {
    endpoint_ok('background_app', [ 5 ], { seconds => 5 });
    endpoint_ok('is_app_installed', [ 'a fake bundle id' ], { bundleId => 'a fake bundle id' });
    endpoint_ok('install_app', [ '/fake/path/to.app' ], { appPath => '/fake/path/to.app' });
    endpoint_ok('remove_app', [ '/fake/path/to.app' ], { appId => '/fake/path/to.app' });
    endpoint_ok('launch_app');
    endpoint_ok('close_app');
}

DEVICE: {
    endpoint_ok('lock', [ 5 ], { seconds => 5 });
    endpoint_ok('is_locked');
    endpoint_ok('shake');
    endpoint_ok('open_notifications');
    endpoint_ok('network_connection');
    endpoint_ok('set_network_connection', [ 6 ], { parameters => { type => 6 } });
}

MISC: {
    endpoint_ok('end_test_coverage', [ 'intent', 'path' ], {
        intent => 'intent',
        path => 'path'
    });

    ok($mock_appium->can('tap'), 'tap: Appium can tap');
    lives_ok(sub { $mock_appium->tap }, 'tap: and we can tap without dying');
}

done_testing;



( run in 0.742 second using v1.01-cache-2.11-cpan-f56aa216473 )