~mial/ubuntu/oneiric/unity/bug-791810

« back to all changes in this revision

Viewing changes to tests/TestPlacesTiles.cpp

Import the work done so far with Compiz

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright 2010 Canonical Ltd.
3
 
 *
4
 
 * This program is free software: you can redistribute it and/or modify it
5
 
 * under the terms of the GNU General Public License version 3, as published
6
 
 * by the  Free Software Foundation.
7
 
 *
8
 
 * This program is distributed in the hope that it will be useful, but
9
 
 * WITHOUT ANY WARRANTY; without even the implied warranties of
10
 
 * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
11
 
 * PURPOSE.  See the GNU General Public License for more details.
12
 
 *
13
 
 * You should have received a copy of the GNU General Public License
14
 
 * version 3 along with this program.  If not, see
15
 
 * <http://www.gnu.org/licenses/>
16
 
 *
17
 
 * Authored by: Gordon Allott <gord.allott@canonical.com>
18
 
 *
19
 
 */
20
 
 
21
 
#include "Nux/Nux.h"
22
 
#include "Nux/VLayout.h"
23
 
#include "Nux/HLayout.h"
24
 
#include "Nux/Button.h"
25
 
#include "IconTexture.h"
26
 
#include "StaticCairoText.h"
27
 
#include "Nux/TextureArea.h"
28
 
#include "Nux/WindowThread.h"
29
 
#include "NuxGraphics/GraphicsEngine.h"
30
 
#include <gtk/gtk.h>
31
 
 
32
 
#include "PlacesSimpleTile.h"
33
 
 
34
 
class TestRunner
35
 
{
36
 
public:
37
 
  TestRunner();
38
 
  ~TestRunner();
39
 
 
40
 
  static void InitWindowThread(nux::NThread* thread, void* InitData);
41
 
  void Init();
42
 
  nux::HLayout* layout;
43
 
  PlacesSimpleTile* simple_tile;
44
 
 
45
 
private:
46
 
 
47
 
};
48
 
 
49
 
TestRunner::TestRunner()
50
 
{
51
 
}
52
 
 
53
 
TestRunner::~TestRunner()
54
 
{
55
 
}
56
 
 
57
 
void TestRunner::Init()
58
 
{
59
 
  PlacesSimpleTile* tile1 = new PlacesSimpleTile("/usr/share/icons/scalable/apps/deluge.svg", "Der schnelle braune Fuchs sprang über den faulen Hund. Der schnelle braune Fuchs sprang über den faulen Hund. Der schnelle braune Fuchs sprang über den faulen Hund.");
60
 
  PlacesSimpleTile* tile2 = new PlacesSimpleTile("firefox", "FooBar Fox");
61
 
  PlacesSimpleTile* tile3 = new PlacesSimpleTile("THISISNOTAVALIDTEXTURE.NOTREAL", "this icon is not valid");
62
 
  layout = new nux::HLayout(NUX_TRACKER_LOCATION);
63
 
 
64
 
  layout->AddView(tile1, 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
65
 
  layout->AddView(tile2, 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
66
 
  layout->AddView(tile3, 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
67
 
 
68
 
  layout->SetFocused(true);
69
 
 
70
 
  nux::GetGraphicsThread()->SetLayout(layout);
71
 
}
72
 
 
73
 
void TestRunner::InitWindowThread(nux::NThread* thread, void* InitData)
74
 
{
75
 
  TestRunner* self = (TestRunner*) InitData;
76
 
  self->Init();
77
 
}
78
 
 
79
 
void
80
 
ControlThread(nux::NThread* thread,
81
 
              void*         data)
82
 
{
83
 
  // sleep for 3 seconds
84
 
  nux::SleepForMilliseconds(3000);
85
 
  printf("ControlThread successfully started\n");
86
 
}
87
 
 
88
 
 
89
 
int main(int argc, char** argv)
90
 
{
91
 
  nux::SystemThread* st = NULL;
92
 
  nux::WindowThread* wt = NULL;
93
 
 
94
 
  // no real tests right now, just make sure we don't get any criticals and such
95
 
  // waiting on nice perceptual diff support before we can build real tests
96
 
  // for views
97
 
 
98
 
  g_type_init();
99
 
  g_thread_init(NULL);
100
 
  gtk_init(&argc, &argv);
101
 
 
102
 
  nux::NuxInitialize(0);
103
 
 
104
 
  g_setenv("UNITY_ENABLE_PLACES", "1", FALSE);
105
 
 
106
 
  TestRunner* test_runner = new TestRunner();
107
 
  wt = nux::CreateGUIThread(TEXT("Unity Places Tile Test"),
108
 
                            1024, 600,
109
 
                            0,
110
 
                            &TestRunner::InitWindowThread,
111
 
                            test_runner);
112
 
 
113
 
  st = nux::CreateSystemThread(NULL, ControlThread, wt);
114
 
 
115
 
  if (st)
116
 
    st->Start(NULL);
117
 
 
118
 
  wt->Run(NULL);
119
 
  delete st;
120
 
  delete wt;
121
 
  return 0;
122
 
}