03-spec-coverage.t 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #!perl
  2. use strict;
  3. use warnings;
  4. use Test::More;
  5. unless($ENV{RELEASE_TESTING}) {
  6. plan(skip_all=>"Author tests not required for installation.");
  7. }
  8. eval {use LWP::Simple;};
  9. plan skip_all => "need LWP::Simple" if $@;
  10. use Selenium::Remote::Commands;
  11. my $uri = "http://selenium.googlecode.com/svn/wiki/JsonWireProtocol.wiki";
  12. my $data = get($uri);
  13. plan skip_all => "need internet connection to run spec test" if !$data;
  14. my $todo_list = {
  15. 'GET session/:sessionId/orientation' => 1,
  16. 'POST session/:sessionId/orientation' => 1,
  17. 'POST session/:sessionId/ime/deactivate' => 1,
  18. 'GET session/:sessionId/ime/activated' => 1,
  19. 'POST session/:sessionId/ime/activate' => 1,
  20. 'GET session/:sessionId/ime/active_engine' => 1,
  21. 'GET session/:sessionId/ime/available_engines' => 1,
  22. 'POST session/:sessionId/touch/click' => 1,
  23. 'POST session/:sessionId/touch/down' => 1,
  24. 'POST session/:sessionId/touch/up' => 1,
  25. };
  26. my @lines = split(/\n/, $data);
  27. my @methods;
  28. for my $line (@lines) {
  29. if ($line =~
  30. /\|\|\s*(GET|POST|DELETE)\s*\|\|\s*\[\S*\s+\/([^\]]*)\]\s*\|\|\s*([^\|]*?)\s*\|\|/
  31. ) {
  32. my $method = {method => $1, path => $2, desc => $3};
  33. push @methods, $method;
  34. }
  35. }
  36. my $commands = Selenium::Remote::Commands->new;
  37. SOURCE_COMMAND: for my $method_source (@methods) {
  38. my $command = "$method_source->{method} $method_source->{path}";
  39. my $msg = "find $command";
  40. for my $method_local (values %{$commands}) {
  41. if ( $method_local->{url} eq $method_source->{path}
  42. and $method_local->{method} eq $method_source->{method}) {
  43. pass($msg);
  44. next SOURCE_COMMAND;
  45. }
  46. }
  47. TODO: {
  48. local $TODO = "need to create command" if $todo_list->{$command};
  49. fail($msg);
  50. }
  51. }
  52. LOCAL_COMMAND: for my $method_local (values %{$commands}) {
  53. my $msg = "extra command $method_local->{method} $method_local->{url}";
  54. for my $method_source (@methods) {
  55. if ( $method_local->{url} eq $method_source->{path}
  56. and $method_local->{method} eq $method_source->{method}) {
  57. next LOCAL_COMMAND;
  58. }
  59. }
  60. TODO: {
  61. local $TODO = "Investigate extra methods";
  62. fail($msg);
  63. }
  64. }
  65. done_testing;