This file is indexed.

/usr/lib/Wt/test/paintdevice/WRasterTest.C is in witty-examples 3.1.10-1ubuntu2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
/*
 * Copyright (C) 2011 Emweb bvba, Kessel-Lo, Belgium.
 *
 * See the LICENSE file for terms of use.
 */
#ifdef WT_HAS_WRASTERIMAGE

#include <boost/test/unit_test.hpp>

#include <iostream>
#include <fstream>

#include <Wt/WRasterImage>
#include <Wt/WPainter>
#include <Wt/WPointF>
#include <Wt/Test/WTestEnvironment>
#include <Wt/Render/WTextRenderer>

namespace {
  using namespace Wt;

  class MultiLineTextRenderer : public Wt::Render::WTextRenderer
  {
  public:
    MultiLineTextRenderer(WPainter& painter, const WRectF& rect)
      : painter_(painter),
	rect_(rect)
    { }
    
    virtual double pageWidth(int page) const {
      return rect_.right();
    }
    
    virtual double pageHeight(int page) const {
      return 1E9;
    }
    
    virtual double margin(Side side) const {
      switch (side) {
    case Top: return rect_.top(); break;
      case Left: return rect_.left(); break;
      default:
      return 0;
      }
    }

    virtual WPaintDevice *startPage(int page) {
      if (page > 0)
	assert(false);
      
      return painter_.device();
    }
    
    virtual void endPage(WPaintDevice *device) {
    }

    virtual WPainter *getPainter(WPaintDevice *device) {
      return &painter_;
    }
    
  private:
    WPainter& painter_;
    WRectF    rect_;
  };
}

BOOST_AUTO_TEST_CASE( raster_test_textRenderer )
{
  Wt::Test::WTestEnvironment environment;
  Wt::WApplication app(environment);

  Wt::WRasterImage rasterImage("png", 357, 193);
  {
    Wt::WPainter p(&rasterImage);
    std::string text = 
      "<table style=\"width:357px;\"><tr><td style=\"padding:0px;height:"
      "193px;color:rgb(247,17,117);text-align:left;vertical-align:top;"
      "font-family: Arial;font-size: 60.0pt;font-weight: normal;\">"
      "xxx</td></tr></table>";
    MultiLineTextRenderer renderer(p, WRectF(0, 0, 357, 193));
    renderer.render(text);
  }

  std::ofstream f("text_render_image_1.png");
  rasterImage.write(f);
}

BOOST_AUTO_TEST_CASE( raster_test_dataUriImage )
{
  Wt::Test::WTestEnvironment environment;
  Wt::WApplication app(environment);

  Wt::WRasterImage rasterImage("png", 80, 80);
  Wt::WPainter p(&rasterImage);

  {
    std::string uri 
      = "data:image/gif;base64,R0lGODdhMAAwAPAAAAAAAP///ywAAAAAMAAw"
      "AAAC8IyPqcvt3wCcDkiLc7C0qwyGHhSWpjQu5yqmCYsapyuvUUlvONmOZtfzgFz"
      "ByTB10QgxOR0TqBQejhRNzOfkVJ+5YiUqrXF5Y5lKh/DeuNcP5yLWGsEbtLiOSp"
      "a/TPg7JpJHxyendzWTBfX0cxOnKPjgBzi4diinWGdkF8kjdfnycQZXZeYGejmJl"
      "ZeGl9i2icVqaNVailT6F5iJ90m6mvuTS4OK05M0vDk0Q4XUtwvKOzrcd3iq9uis"
      "F81M1OIcR7lEewwcLp7tuNNkM3uNna3F2JQFo97Vriy/Xl4/f1cf5VWzXyym7PH"
      "hhx4dbgYKAAA7";
    
    Wt::WPainter::Image image(uri, 48, 48);
    p.drawImage(Wt::WPointF(0,0), image);
  }
  
  {
    bool error = false;
    try {
      std::string uri = "data:image/gif;,R0lGODdhMAAwAPAAAAAAAP///ywAAAAAMAAw";
    
      Wt::WPainter::Image image(uri, 48, 48);
      p.drawImage(Wt::WPointF(0,0), image);
    } catch (...) {
      error = true;
    }
    BOOST_REQUIRE(error);
  }
  
  {
    bool error = false;
    try {
      std::string uri 
	= "data:image/tiff;base64,R0lGODdhMAAwAPAAAAAAAP///ywAAAAAMAAw";
    
      Wt::WPainter::Image image(uri, 48, 48);
      p.drawImage(Wt::WPointF(0,0), image);
    } catch (...) {
      error = true;
    }
    BOOST_REQUIRE(error);
  }

  {
    bool error = false;
    try {
      std::string uri 
	= "data:;base64,R0lGODdhMAAwAPAAAAAAAP///ywAAAAAMAAw";
    
      Wt::WPainter::Image image(uri, 48, 48);
      p.drawImage(Wt::WPointF(0,0), image);
    } catch (...) {
      error = true;
    }
    BOOST_REQUIRE(error);
  }

  {
    bool error = false;
    try {
      std::string uri = "data:;base64,R0lGODdhMAAwAPAAAAAAAP///ywAAAAAMAAw";
    
      Wt::WPainter::Image image(uri, 48, 48);
      p.drawImage(Wt::WPointF(0,0), image);
    } catch (...) {
      error = true;
    }
    BOOST_REQUIRE(error);
  }

  {
    bool error = false;
    try {
      std::string uri = "data:image/gif;base64,";
    
      Wt::WPainter::Image image(uri, 48, 48);
      p.drawImage(Wt::WPointF(0,0), image);
    } catch (...) {
      error = true;
    }
    BOOST_REQUIRE(error);
  }
  
  p.end();
  std::ofstream f("data_uri_image.png");
  rasterImage.write(f);
}

#endif