File: RefEncoder.C

package info (click to toggle)
witty 3.3.3%2Bdfsg-4.1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 28,228 kB
  • ctags: 26,694
  • sloc: cpp: 147,809; ansic: 77,999; xml: 16,331; sh: 1,303; makefile: 198; java: 86; sql: 14
file content (106 lines) | stat: -rw-r--r-- 2,427 bytes parent folder | download
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
/*
 * Copyright (C) 2013 Emweb bvba, Kessel-Lo, Belgium.
 *
 * See the LICENSE file for terms of use.
 */
#include <boost/test/unit_test.hpp>

#include <sstream>
#include <Wt/WAnchor>
#include <Wt/WImage>
#include <Wt/WText>
#include <Wt/Test/WTestEnvironment>
#include <Wt/WApplication>

using namespace Wt;

BOOST_AUTO_TEST_CASE(test_trampoline1)
{
  Wt::Test::WTestEnvironment env;
  env.setSessionIdInUrl(true);

  Wt::WApplication app(env);

  {
    Wt::WText t("<div style=\"background-image: "
		"url(http://www.google.be)\"></div>");

    std::stringstream s;
    t.htmlText(s);

    std::size_t red = s.str().find
      ("?request=redirect&amp;url=http%3a//www.google.be&amp;hash=");

    BOOST_REQUIRE(red != std::string::npos);
  }

  {
    Wt::WText t("<div style=\"background-image: "
		"url('http://www.google.be')\"></div>");
    std::stringstream s;
    t.htmlText(s);

    std::size_t red = s.str().find
      ("?request=redirect&amp;url=http%3a//www.google.be&amp;hash=");

    BOOST_REQUIRE(red != std::string::npos);
  }

  {
    Wt::WText t("<div style=\"background-image: "
		"url('http://www.google.be')\">"
		"<span style=\"background-image: "
		"url('http://www.webtoolkit.eu')\"></span></div>");
    std::stringstream s;
    t.htmlText(s);

    std::size_t red = s.str().find
      ("?request=redirect&amp;url=http%3a//www.google.be&amp;hash=");

    BOOST_REQUIRE(red != std::string::npos);

    red = s.str().find
      ("?request=redirect&amp;url=http%3a//www.webtoolkit.eu&amp;hash=");

    BOOST_REQUIRE(red != std::string::npos);
  }

  {
    Wt::WImage img("http://www.google.be");
    
    std::stringstream s;
    img.htmlText(s);

    std::size_t red = s.str().find
      ("?request=redirect&amp;url=http%3a//www.google.be&amp;hash=");

    BOOST_REQUIRE(red != std::string::npos);
  }

  {
    Wt::WAnchor img("http://www.google.be");
    
    std::stringstream s;
    img.htmlText(s);

    std::size_t red = s.str().find
      ("?request=redirect&amp;url=http%3a//www.google.be&amp;hash=");

    BOOST_REQUIRE(red != std::string::npos);
  }

  {
    Wt::WContainerWidget w;
    w.decorationStyle().setBackgroundImage("http://www.google.be");

    std::stringstream s;
    w.htmlText(s);

    std::cerr << s.str() << std::endl;

    std::size_t red = s.str().find
      ("?request=redirect&amp;url=http%3a//www.google.be&amp;hash=");

    BOOST_REQUIRE(red != std::string::npos);
  }    
}