Merge changes I88ded17f,I3960a370 into devel/master
authorPaul Wisbey <p.wisbey@samsung.com>
Tue, 9 Aug 2016 17:30:56 +0000 (10:30 -0700)
committerGerrit Code Review <gerrit@review.vlan103.tizen.org>
Tue, 9 Aug 2016 17:30:56 +0000 (10:30 -0700)
* changes:
  Fix for multi-language support.
  Text - UTC fixes after removing non latin characters from the LATIN script in adaptor.

automated-tests/patch-coverage.pl
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-adaptor.cpp
automated-tests/src/dali-toolkit/utc-Dali-VisualFactory.cpp
dali-toolkit/internal/controls/effects-view/effects-view-impl.cpp
dali-toolkit/internal/filters/emboss-filter.cpp
dali-toolkit/internal/visuals/visual-factory-impl.cpp

index 68754eb..c19953b 100755 (executable)
@@ -45,16 +45,14 @@ our $repo = Git->repository();
 our $debug=0;
 our $pd_debug=0;
 our $opt_cached;
-our $opt_head;
-#our $opt_workingtree;
-#our $opt_diff=1;
 our $opt_help;
-our $opt_verbose;
+our $opt_output;
 our $opt_quiet;
+our $opt_verbose;
 
 my %options = (
     "cached"       => { "optvar"=>\$opt_cached, "desc"=>"Use index" },
-    "head"         => { "optvar"=>\$opt_head, "desc"=>"Use git show" },
+    "output:s"     => { "optvar"=>\$opt_output, "desc"=>"Generate html output"},
     "help"         => { "optvar"=>\$opt_help, "desc"=>""},
     "quiet"        => { "optvar"=>\$opt_quiet, "desc"=>""},
     "verbose"      => { "optvar"=>\$opt_verbose, "desc"=>"" });
@@ -323,6 +321,7 @@ sub get_coverage
 # output for the patch.
 sub run_diff
 {
+    #print "run_diff(" . join(" ", @_) . ")\n";
     my ($fh, $c) = $repo->command_output_pipe(@_);
     our @patch=();
     while(<$fh>)
@@ -332,6 +331,8 @@ sub run_diff
     }
     $repo->command_close_pipe($fh, $c);
 
+    print "Patch size: " . scalar(@patch) . "\n" if $debug;
+
     # @patch has slurped diff for all files...
     my $filesref = parse_diff ( \@patch );
     show_patch_lines($filesref) if $debug;
@@ -344,6 +345,7 @@ sub run_diff
     for my $file (keys(%$filesref))
     {
         my ($name, $path, $suffix) = fileparse($file, qr{\.[^.]*$});
+        next if($path !~ /^dali/);
         if($suffix eq ".cpp" || $suffix eq ".c" || $suffix eq ".h")
         {
             get_coverage($file, $filesref);
@@ -353,7 +355,6 @@ sub run_diff
     return $filesref;
 }
 
-
 sub calc_patch_coverage_percentage
 {
     my $filesref = shift;
@@ -362,6 +363,9 @@ sub calc_patch_coverage_percentage
 
     foreach my $file (keys(%$filesref))
     {
+        my ($name, $path, $suffix) = fileparse($file, qr{\.[^.]*$});
+        next if($path !~ /^dali/);
+
         my $covered_lines = 0;
         my $uncovered_lines = 0;
 
@@ -401,7 +405,7 @@ sub calc_patch_coverage_percentage
     my $percent = 0;
     if($total_exec > 0) { $percent = 100 * $total_covered_lines / $total_exec; }
 
-    return $percent;
+    return [ $total_exec, $percent ];
 }
 
 sub patch_output
@@ -480,6 +484,117 @@ sub patch_output
 }
 
 
+sub patch_html_output
+{
+    my $filesref = shift;
+
+    open( my $filehandle, ">", $opt_output ) || die "Can't open $opt_output for writing:$!\n";
+
+    my $OUTPUT_FH = select;
+    select $filehandle;
+    print <<EOH;
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
+"http://www.w3.org/TR/REC-html40/loose.dtd">
+<html>
+<head>
+<title>Patch Coverage</title>
+</head>
+<body bgcolor="white">
+EOH
+
+    foreach my $file (keys(%$filesref))
+    {
+        my ($name, $path, $suffix) = fileparse($file, qr{\.[^.]*$});
+        next if($path !~ /^dali/);
+
+        my $patchref = $filesref->{$file}->{"patch"};
+        my $b_lines_ref = $filesref->{$file}->{"b_lines"};
+        my $coverage_ref = $filesref->{$file}->{"coverage"};
+        print "<h2>$file</h2>\n";
+
+        if($coverage_ref)
+        {
+            if( $coverage_ref->{"covered_lines"} > 0
+                ||
+                $coverage_ref->{"uncovered_lines"} > 0 )
+            {
+                print "<p style=\"color:green;\">Covered: " .
+                    $coverage_ref->{"covered_lines"} . "<p>" .
+                    "<p style=\"color:red;\">Uncovered: " .
+                    $coverage_ref->{"uncovered_lines"} . "</span></p>";
+            }
+        }
+        else
+        {
+            print "<p>";
+            my $span=0;
+            if($suffix eq ".cpp" || $suffix eq ".c" || $suffix eq ".h")
+            {
+                print "<span style=\"color:red;\">";
+                $span=1;
+            }
+            print "No coverage found";
+            print "</span>" if $span;
+        }
+        print "</p>";
+
+        for my $patch (@$patchref)
+        {
+            my $hunkstr="Hunk: " . $patch->[0];
+            if( $patch->[1] > 1 )
+            {
+                $hunkstr .= " - " . ($patch->[0]+$patch->[1]-1);
+            }
+            print "<p style=\"font-weight:bold;\">" . $hunkstr . "</p>";
+
+            print "<pre>";
+            for(my $i = 0; $i < $patch->[1]; $i++ )
+            {
+                my $line = $i + $patch->[0];
+                my $num_line_digits=log($line)/log(10);
+                for $i (0..(6-$num_line_digits-1))
+                {
+                    print " ";
+                }
+                print "$line  ";
+
+                if($coverage_ref)
+                {
+                    my $color;
+                    if($coverage_ref->{"covered"}->{$line})
+                    {
+                        print("<span style=\"color:green;\">");
+                    }
+                    elsif($coverage_ref->{"uncovered"}->{$line})
+                    {
+                        print("<span style=\"color:red;font-weight:bold;\">");
+                    }
+                    else
+                    {
+                        #print("<span style=\"color:black;font-weight:normal;\">");
+                    }
+                    my $src=$coverage_ref->{"src"}->{$line};
+                    chomp($src);
+                    #print $color, "$src\n", RESET;
+                    print "$src</span>\n";
+                }
+                else
+                {
+                    # We don't have coverage data, so print it from the patch instead.
+                    my $src = $b_lines_ref->{$line};
+                    print "$src\n";
+                }
+            }
+            print "<\pre>\n";
+        }
+    }
+
+    print $filehandle "<hr>\n</body>\n</html>\n";
+    close $filehandle;
+    select $OUTPUT_FH;
+}
+
+
 ################################################################################
 ##                                    MAIN                                    ##
 ################################################################################
@@ -492,30 +607,82 @@ chdir "build/tizen";
 my @cmd=('--no-pager','diff','--no-ext-diff','-U0','--no-color');
 
 my $status = $repo->command("status", "-s");
-if( $status eq "" )
+if( $status eq "" && !scalar(@ARGV))
 {
-    # There are no changes in the index or working tree. Use the last patch instead
+    # There are no changes in the index or working tree, and
+    # no diff arguments to append. Use the last patch instead.
     push @cmd, ('HEAD~1','HEAD');
 }
-elsif($opt_cached) # TODO: Remove this option. Instead, need full diff
+else
 {
-    push @cmd, "--cached";
+    # detect if there are only cached changes or only working tree changes
+    my $cached = 0;
+    my $working = 0;
+    for my $fstat ( split(/\n/, $status) )
+    {
+        if(substr( $fstat, 0, 1 ) ne " "){ $cached++; }
+        if(substr( $fstat, 1, 1 ) ne " "){ $working++; }
+    }
+    if($cached > 0 )
+    {
+        if($working == 0)
+        {
+            push @cmd, "--cached";
+        }
+        else
+        {
+            die "Both cached & working files - cannot get correct patch from git\n";
+            # Would have to diff from separate clone.
+        }
+    }
 }
 
 push @cmd, @ARGV;
 my $filesref = run_diff(@cmd);
 
-my $percent = calc_patch_coverage_percentage($filesref);
-if( ! $opt_quiet )
+chdir $cwd;
+
+# Check how many actual source files there are in the patch
+my $filecount = 0;
+foreach my $file (keys(%$filesref))
+{
+    my ($name, $path, $suffix) = fileparse($file, qr{\.[^.]*$});
+    next if($path !~ /^dali/);
+    next if($suffix ne ".cpp" && $suffix ne ".c" && $suffix ne ".h");
+    $filecount++;
+}
+if( $filecount == 0 )
+{
+    print "No source files found\n";
+    exit 0;    # Exit with no error.
+}
+
+my $percentref = calc_patch_coverage_percentage($filesref);
+if($percentref->[0] == 0)
+{
+    print "No coverable lines found\n";
+    exit 0;
+}
+my $percent = $percentref->[1];
+
+my $color=BOLD RED;
+if($opt_output)
+{
+    print "Outputing to $opt_output\n" if $debug;
+    patch_html_output($filesref);
+}
+elsif( ! $opt_quiet )
 {
     patch_output($filesref);
-    my $color=BOLD RED;
     if($percent>=90)
     {
         $color=GREEN;
     }
-    printf("Percentage of change covered: $color %5.2f%\n" . RESET, $percent);
+    print RESET;
 }
+
+printf("Percentage of change covered: %5.2f%\n", $percent);
+
 exit($percent<90);
 
 
index ebab526..4e884e0 100644 (file)
@@ -64,6 +64,7 @@ public:
 
   virtual void SetThreadSynchronization( ThreadSynchronizationInterface& threadSynchronization ) {}
 
+  virtual RenderSurface::Type GetSurfaceType() { return RenderSurface::ECORE_RENDER_SURFACE; }
 };
 
 namespace Internal
index 76d6aac..53eee06 100644 (file)
@@ -880,13 +880,13 @@ int UtcDaliVisualFactoryGetNPatchVisualN2(void)
   //This should still load but display an error image
 
   ToolkitTestApplication application;
-  tet_infoline( "UtcDaliVisualFactoryGetNPatchVisualN: Request n-patch visual with an invalid Property::Map" );
+  tet_infoline( "UtcDaliVisualFactoryGetNPatchVisualN: Request n-patch visual with an invalid URL" );
 
   VisualFactory factory = VisualFactory::Get();
   DALI_TEST_CHECK( factory );
 
   Property::Map propertyMap;
-  propertyMap.Insert( Visual::Property::TYPE,  111 );
+  propertyMap.Insert( Visual::Property::TYPE,  Visual::IMAGE );
   propertyMap.Insert( ImageVisual::Property::URL,  "ERROR.9.jpg" );
 
   Visual::Base visual = factory.CreateVisual( propertyMap );
@@ -911,6 +911,26 @@ int UtcDaliVisualFactoryGetNPatchVisualN2(void)
   END_TEST;
 }
 
+int UtcDaliVisualFactoryGetNPatchVisualN3(void)
+{
+  // Passing in an invalid visual type so we should not get a visual
+
+  ToolkitTestApplication application;
+  tet_infoline( "UtcDaliVisualFactoryGetNPatchVisualN: Request n-patch visual with an invalid visual type" );
+
+  VisualFactory factory = VisualFactory::Get();
+  DALI_TEST_CHECK( factory );
+
+  Property::Map propertyMap;
+  propertyMap.Insert( Visual::Property::TYPE,  111 );
+  propertyMap.Insert( ImageVisual::Property::URL,  "ERROR.9.jpg" );
+
+  Visual::Base visual = factory.CreateVisual( propertyMap );
+  DALI_TEST_CHECK( !visual );
+
+  END_TEST;
+}
+
 int UtcDaliVisualFactoryGetSvgVisual(void)
 {
   ToolkitTestApplication application;
index 70dbd3f..ed94ff8 100644 (file)
@@ -36,6 +36,7 @@
 #include <dali-toolkit/internal/filters/blur-two-pass-filter.h>
 #include <dali-toolkit/internal/filters/emboss-filter.h>
 #include <dali-toolkit/internal/filters/spread-filter.h>
+#include <dali-toolkit/internal/visuals/visual-base-impl.h>
 
 namespace Dali
 {
@@ -161,8 +162,6 @@ void EffectsView::SetType( Toolkit::EffectsView::EffectType type )
     RemoveFilters();
 
     Actor self = Self();
-    Property::Map visualMap;
-    visualMap.Insert( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE );
 
     switch( type )
     {
@@ -185,11 +184,12 @@ void EffectsView::SetType( Toolkit::EffectsView::EffectType type )
       }
     }
 
+    Image dummyImage; // Dummy image, force creation of an image visual
+    InitializeVisual( self, mVisualPostFilter, dummyImage );
     Property::Map customShader;
     customShader[ Toolkit::Visual::Shader::Property::VERTEX_SHADER ] = EFFECTS_VIEW_VERTEX_SOURCE;
     customShader[ Toolkit::Visual::Shader::Property::FRAGMENT_SHADER ] = EFFECTS_VIEW_FRAGMENT_SOURCE;
-    visualMap[ Toolkit::Visual::Property::SHADER ] = customShader;
-    InitializeVisual( self, mVisualPostFilter, visualMap );
+    Toolkit::GetImplementation( mVisualPostFilter ).SetCustomShader( customShader );
 
     mEffectType = type;
   }
index c10d122..4bb7c30 100644 (file)
@@ -30,6 +30,7 @@
 // INTERNAL INCLUDES
 #include <dali-toolkit/public-api/visuals/visual-properties.h>
 #include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
+#include <dali-toolkit/internal/visuals/visual-base-impl.h>
 
 namespace Dali
 {
@@ -123,13 +124,16 @@ void EmbossFilter::Enable()
   mActorForComposite.SetColor( Color::BLACK );
 
   customShader[ Toolkit::Visual::Shader::Property::FRAGMENT_SHADER ] = COMPOSITE_FRAGMENT_SOURCE;
-  visualMap[ Toolkit::Visual::Property::SHADER ] = customShader;
-  visualMap[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
 
   mRootActor.Add( mActorForComposite );
 
-  InitializeVisual( mActorForComposite, mVisualForEmboss1, visualMap );
-  InitializeVisual( mActorForComposite, mVisualForEmboss2, visualMap );
+  Image dummyImage; // Dummy image, force creation of an image visual
+
+  InitializeVisual( mActorForComposite, mVisualForEmboss1, dummyImage );
+  Toolkit::GetImplementation( mVisualForEmboss1 ).SetCustomShader( customShader );
+
+  InitializeVisual( mActorForComposite, mVisualForEmboss2, dummyImage );
+  Toolkit::GetImplementation( mVisualForEmboss2 ).SetCustomShader( customShader );
 
   TextureSet textureSet1 = TextureSet::New();
   TextureSetImage( textureSet1, 0, mImageForEmboss1 );
index 530feb9..df9cbb3 100644 (file)
@@ -136,7 +136,6 @@ Toolkit::Visual::Base VisualFactory::CreateVisual( const Property::Map& property
       break;
     }
 
-    default: // Default to Image type if unknown (check if there is a URL)
     case Toolkit::Visual::IMAGE:
     {
       Property::Value* imageURLValue = propertyMap.Find( Toolkit::ImageVisual::Property::URL, IMAGE_URL_NAME );
@@ -173,13 +172,6 @@ Toolkit::Visual::Base VisualFactory::CreateVisual( const Property::Map& property
           }
         }
       }
-      else if( propertyMap.Find( Toolkit::Visual::Property::SHADER, CUSTOM_SHADER ) )
-      {
-        // Create Image Visual if it has a shader
-        // TODO: This is required because of EffectsView which should be fixed
-        CreateAtlasManager();
-        visualPtr = new ImageVisual( *( mFactoryCache.Get() ), *( mAtlasManager.Get() ) );
-      }
       break;
     }