Android-ElectricSheep-Automator

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

        $mother->navigation_menu_overview_button() or die;
    
        # open/close apps
        $mother->open_app({'package'=>qr/calendar$/i}) or die;
        $mother->close_app({'package'=>qr/calendar$/i}) or die;
    
        # push pull files
        $mother->adb->pull($deviceFile, $localFile);
        $mother->adb->push($localFile, $deviceFileOrDir);
    
        # guess what!
        my $xmlstr = $mother->dump_current_screen_ui();
    
        # Pull the apk(s) for an app from device and save locally
        my $res = $mother->pull_app_apk_from_device({
          package => 'com.google.android.calendar'
            # or qr/calendar/i
          'output-dir' => '/tmp/apks-of-calendar-app',
        });
        print $res->{'com.google.android.calendar'}->[0]->['local-path'};
    

README.md  view on Meta::CPAN

    $mother->navigation_menu_overview_button() or die;

    # open/close apps
    $mother->open_app({'package'=>qr/calendar$/i}) or die;
    $mother->close_app({'package'=>qr/calendar$/i}) or die;

    # push pull files
    $mother->adb->pull($deviceFile, $localFile);
    $mother->adb->push($localFile, $deviceFileOrDir);

    # guess what!
    my $xmlstr = $mother->dump_current_screen_ui();

    # Pull the apk(s) for an app from device and save locally
    my $res = $mother->pull_app_apk_from_device({
      package => 'com.google.android.calendar'
        # or qr/calendar/i
      'output-dir' => '/tmp/apks-of-calendar-app',
    });
    print $res->{'com.google.android.calendar'}->[0]->['local-path'};

lib/Android/ElectricSheep/Automator.pm  view on Meta::CPAN

    $mother->navigation_menu_overview_button() or die;

    # open/close apps
    $mother->open_app({'package'=>qr/calendar$/i}) or die;
    $mother->close_app({'package'=>qr/calendar$/i}) or die;

    # push pull files
    $mother->adb->pull($deviceFile, $localFile);
    $mother->adb->push($localFile, $deviceFileOrDir);

    # guess what!
    my $xmlstr = $mother->dump_current_screen_ui();

    # Pull the apk(s) for an app from device and save locally
    my $res = $mother->pull_app_apk_from_device({
      package => 'com.google.android.calendar'
	# or qr/calendar/i
      'output-dir' => '/tmp/apks-of-calendar-app',
    });
    print $res->{'com.google.android.calendar'}->[0]->['local-path'};

xt/author/500-install_app.t  view on Meta::CPAN

	#'verbosity' => $VERBOSITY,
	# we have a device connected and ready to control
	'device-is-connected' => 1,
});
ok(defined($mother), 'Android::ElectricSheep::Automator->new()'." : called and got defined result.") or BAIL_OUT;

my $devobj = $mother->connect_device();
ok(defined($devobj), 'connect_device()'." : called and got good result.") or BAIL_OUT;

# this app should exist
# we are sure this app exists on a virgin phone i guess?
my $apkfilename = File::Spec->catfile($curdir, '..', '..', 't', 't-data', 'apks', 'Gallery2.apk');
ok(-e $apkfilename, "input APK file '$apkfilename' exists.") or BAIL_OUT;

my $sparams = {
	'apk-filename', $apkfilename,
	'install-parameters' => [
		'-r', # reinstall
		'-g', # Grant all permissions listed in the app manifest.
	]
};

xt/live/420-adb-pidof.t  view on Meta::CPAN


my $mother = Android::ElectricSheep::Automator->new({
	'configfile' => $configfile,
	#'verbosity' => $VERBOSITY,
	# we have a device connected and ready to control
	'device-is-connected' => 1,
});
ok(defined($mother), 'Android::ElectricSheep::Automator->new()'." : called and got defined result.") or BAIL_OUT;

# this app should exist
# we are sure this app exists on a virgin phone i guess?
my $name = 'com.google.android.apps.messaging';
my $res = $mother->pidof({'name' => $name});
ok(defined($res), 'Android::ElectricSheep::Automator->pidof()'." : called and got good result.") or BAIL_OUT;
is(ref($res), '', 'Android::ElectricSheep::Automator->pidof()'." : called and got good result which is a SCALAR.") or BAIL_OUT("no it is '".ref($res)."'");
ok($res >= 0, 'Android::ElectricSheep::Automator->pidof()'." : called and got good result which is a pid > 0 (meaning success).") or BAIL_OUT("no it is '$res'.");
diag "got pid of app '$name' to be '$res'.";

# this should not exist
# we are sure this app exists on a virgin phone i guess?
my $name = 'crazy.xxx.yyy.zzz';
my $res = $mother->pidof({'name' => $name});
ok(defined($res), 'Android::ElectricSheep::Automator->pidof()'." : called and got good result.") or BAIL_OUT;
is(ref($res), '', 'Android::ElectricSheep::Automator->pidof()'." : called and got good result which is a SCALAR.") or BAIL_OUT("no it is '".ref($res)."'");
is($res, -1, 'Android::ElectricSheep::Automator->pidof()'." : called and got good result which is -1, indicating that this app is not running, as expected.") or BAIL_OUT("no it is '$res'.");


#diag "temp dir: $tmpdir ..." if exists($ENV{'PERL_TEST_TEMPDIR_TINY_NOCLEANUP'}) && $ENV{'PERL_TEST_TEMPDIR_TINY_NOCLEANUP'}>0;

# END

xt/live/460-is_app_running.t  view on Meta::CPAN


my $mother = Android::ElectricSheep::Automator->new({
	'configfile' => $configfile,
	#'verbosity' => $VERBOSITY,
	# we have a device connected and ready to control
	'device-is-connected' => 1,
});
ok(defined($mother), 'Android::ElectricSheep::Automator->new()'." : called and got defined result.") or BAIL_OUT;

# this app should exist
# we are sure this app exists on a virgin phone i guess?
my $appname = 'com.google.android.apps.messaging';
my $res = $mother->is_app_running({'appname' => $appname});
ok(defined($res), 'Android::ElectricSheep::Automator->is_app_running()'." : called and got good result.") or BAIL_OUT;
is(ref($res), '', 'Android::ElectricSheep::Automator->is_app_running()'." : called and got good result which is a SCALAR.") or BAIL_OUT("no it is '".ref($res)."'");
is($res, 1, 'Android::ElectricSheep::Automator->is_app_running()'." : called and got good result which is 1 meaning the app is running as expected.") or BAIL_OUT("no it is '$res'.");

# this should not exist
# we are sure this app exists on a virgin phone i guess?
my $appname = 'crazy.xxx.yyy.zzz';
my $res = $mother->is_app_running({'appname' => $appname});
ok(defined($res), 'Android::ElectricSheep::Automator->is_app_running()'." : called and got good result.") or BAIL_OUT;
is(ref($res), '', 'Android::ElectricSheep::Automator->is_app_running()'." : called and got good result which is a SCALAR.") or BAIL_OUT("no it is '".ref($res)."'");
is($res, 0, 'Android::ElectricSheep::Automator->is_app_running()'." : called and got good result which is 0, indicating that this app is not running, as expected.") or BAIL_OUT("no it is '$res'.");


#diag "temp dir: $tmpdir ..." if exists($ENV{'PERL_TEST_TEMPDIR_TINY_NOCLEANUP'}) && $ENV{'PERL_TEST_TEMPDIR_TINY_NOCLEANUP'}>0;

# END

xt/live/480-pull_app_apk_from_device.t  view on Meta::CPAN

	#'verbosity' => $VERBOSITY,
	# we have a device connected and ready to control
	'device-is-connected' => 1,
});
ok(defined($mother), 'Android::ElectricSheep::Automator->new()'." : called and got defined result.") or BAIL_OUT;

my $devobj = $mother->connect_device();
ok(defined($devobj), 'connect_device()'." : called and got good result.") or BAIL_OUT;

# this app should exist
# we are sure this app exists on a virgin phone i guess?
my $appname = qr/gallery/i; # com.android.gallery2
my $sparams = {
	'output-dir' => $outdir,
	'package' => $appname,
	'lazy' => 1,
};
my $res = $mother->pull_app_apk_from_device($sparams);
ok(defined($res), 'Android::ElectricSheep::Automator->pull_app_apk_from_device()'." : called and got good result.") or BAIL_OUT(perl2dump($sparams)."no, it failed, see above params.");
is(ref($res), 'HASH', 'Android::ElectricSheep::Automator->pull_app_apk_from_device()'." : called and got good result which is a HASH_REF.") or BAIL_OUT("no it is '".ref($res)."'");
for my $packagename (sort keys %$res){



( run in 2.579 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )