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

« back to all changes in this revision

Viewing changes to tests/TestPreviewMusic.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/Button.h"
24
 
#include "Nux/TextureArea.h"
25
 
#include "Nux/WindowThread.h"
26
 
#include "NuxGraphics/GraphicsEngine.h"
27
 
#include <gtk/gtk.h>
28
 
 
29
 
#include "PreviewBasicButton.h"
30
 
#include "PreviewMusic.h"
31
 
#include "DashStyle.h"
32
 
 
33
 
class TestRunner
34
 
{
35
 
public:
36
 
  TestRunner ();
37
 
  ~TestRunner ();
38
 
 
39
 
  static void InitWindowThread (nux::NThread* thread, void* InitData);
40
 
  void Init ();
41
 
  nux::Layout *layout;
42
 
 
43
 
private:
44
 
 
45
 
};
46
 
 
47
 
TestRunner::TestRunner ()
48
 
{
49
 
}
50
 
 
51
 
TestRunner::~TestRunner ()
52
 
{
53
 
}
54
 
 
55
 
void TestRunner::Init ()
56
 
{
57
 
  unity::dash::Preview::Properties properties;
58
 
  unity::dash::AlbumPreview* album_preview = new unity::dash::AlbumPreview (properties);
59
 
 
60
 
  album_preview->name = "Fron: Legacy OST";
61
 
  album_preview->artist = "Daft Funk";
62
 
  album_preview->year = "2011";
63
 
  album_preview->length = (92 * 60) + 32;
64
 
  album_preview->genres.push_back("Funk");
65
 
  album_preview->genres.push_back("Frank");
66
 
 
67
 
  album_preview->tracks.push_back(unity::dash::AlbumPreview::Track(0, "Underture", 90, "foo/play", "foo/pause"));
68
 
  album_preview->tracks.push_back(unity::dash::AlbumPreview::Track(1, "The Grind", 90, "foo/play", "foo/pause"));
69
 
  album_preview->tracks.push_back(unity::dash::AlbumPreview::Track(2, "Daughter of Flan", 90, "foo/play", "foo/pause"));
70
 
  album_preview->tracks.push_back(unity::dash::AlbumPreview::Track(3, "Who?", 90, "foo/play", "foo/pause"));
71
 
  album_preview->tracks.push_back(unity::dash::AlbumPreview::Track(4, "Peace", 90, "foo/play", "foo/pause"));
72
 
  album_preview->tracks.push_back(unity::dash::AlbumPreview::Track(5, "Daggerfall", 90, "foo/play", "foo/pause"));
73
 
 
74
 
  album_preview->album_cover = "firefox.png";
75
 
  album_preview->primary_action_name = "Play Album";
76
 
  album_preview->primary_action_icon_hint = "none";
77
 
  album_preview->primary_action_uri = "play/album";
78
 
 
79
 
  unity::dash::Preview::Ptr preview = unity::dash::Preview::Ptr(album_preview);
80
 
  unity::PreviewMusicAlbum* preview_view = new unity::PreviewMusicAlbum (preview, NUX_TRACKER_LOCATION);
81
 
  preview_view->UriActivated.connect ([] (std::string uri) { g_debug ("Uri Activated: %s", uri.c_str()); });
82
 
  layout = new nux::VLayout(NUX_TRACKER_LOCATION);
83
 
 
84
 
  layout->AddView (preview_view, 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
85
 
 
86
 
  nux::GetGraphicsThread()->SetLayout (layout);
87
 
}
88
 
 
89
 
void TestRunner::InitWindowThread(nux::NThread* thread, void* InitData)
90
 
{
91
 
  TestRunner *self =  (TestRunner *) InitData;
92
 
  self->Init ();
93
 
}
94
 
 
95
 
void
96
 
ControlThread (nux::NThread* thread,
97
 
               void*         data)
98
 
{
99
 
  // sleep for 3 seconds
100
 
  nux::SleepForMilliseconds (3000);
101
 
  printf ("ControlThread successfully started\n");
102
 
}
103
 
 
104
 
 
105
 
int main(int argc, char **argv)
106
 
{
107
 
  nux::SystemThread* st = NULL;
108
 
  nux::WindowThread* wt = NULL;
109
 
 
110
 
  // no real tests right now, just make sure we don't get any criticals and such
111
 
  // waiting on nice perceptual diff support before we can build real tests
112
 
  // for views
113
 
 
114
 
  g_type_init ();
115
 
  g_thread_init (NULL);
116
 
  gtk_init (&argc, &argv);
117
 
 
118
 
  nux::NuxInitialize(0);
119
 
 
120
 
  // The instances for the pseudo-singletons.
121
 
  unity::DashStyle dash_style;
122
 
 
123
 
  TestRunner *test_runner = new TestRunner ();
124
 
  wt = nux::CreateGUIThread(TEXT("Unity Places Tile Test"),
125
 
                            800 , 600,
126
 
                            0,
127
 
                            &TestRunner::InitWindowThread,
128
 
                            test_runner);
129
 
 
130
 
  st = nux::CreateSystemThread (NULL, ControlThread, wt);
131
 
 
132
 
  if (st)
133
 
    st->Start (NULL);
134
 
 
135
 
  wt->Run (NULL);
136
 
  delete st;
137
 
  delete wt;
138
 
  return 0;
139
 
}