~tatokis/unity/gcc-72-errors

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
// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
/*
 * Copyright (C) 2012-2013 Canonical Ltd
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 3 as
 * published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Authored by: Manuel de la Pena <manuel.delapena@canonical.com>
 */

#include <list>
#include <gmock/gmock.h>

#include <Nux/Nux.h>
#include <Nux/VLayout.h>
#include <Nux/BaseWindow.h>
#include <unity-shared/StaticCairoText.h>
#include <unity-shared/CoverArt.h>
#include <unity-shared/DashStyle.h>
#include <unity-shared/PreviewStyle.h>
#include <unity-shared/ThumbnailGenerator.h>

#include <unity-protocol.h>
#include "dash/previews/MusicPaymentPreview.h"
#include "test_utils.h"

using namespace testing;

namespace unity
{

namespace dash
{

namespace previews
{

class MockedMusicPaymentPreview : public MusicPaymentPreview
{
public:
  typedef nux::ObjectPtr<MockedMusicPaymentPreview> Ptr;

  MockedMusicPaymentPreview(dash::Preview::Ptr preview_model)
  : MusicPaymentPreview(preview_model)
  {}

  using MusicPaymentPreview::image_;
  using MusicPaymentPreview::intro_;
  using MusicPaymentPreview::title_;
  using MusicPaymentPreview::subtitle_;
  using MusicPaymentPreview::email_label_;
  using MusicPaymentPreview::email_;
  using MusicPaymentPreview::payment_label_;
  using MusicPaymentPreview::payment_;
  using MusicPaymentPreview::password_label_;
  using MusicPaymentPreview::password_entry_;
  using MusicPaymentPreview::purchase_hint_;
  using MusicPaymentPreview::purchase_prize_;
  using MusicPaymentPreview::purchase_type_;
  using MusicPaymentPreview::change_payment_;
  using MusicPaymentPreview::forgotten_password_;
  using MusicPaymentPreview::error_label_;
  using MusicPaymentPreview::form_layout_;
  using MusicPaymentPreview::SetupViews;
};

class TestMusicPaymentPreview : public ::testing::Test
{
  protected:
  TestMusicPaymentPreview() :
    Test(),
    parent_window_(new nux::BaseWindow("TestPreviewMusicPayment"))
  {
    title = "Turning Japanese";
    subtitle = "The vapors";
    header = "Hi test, you purchased in the past from Ubuntu One.";
    email = "test@canonical.com";
    payment_method = "*** *** ** 12";
    purchase_prize = "65$";
    purchase_type = "Mp3";
    preview_type = UNITY_PROTOCOL_PREVIEW_PAYMENT_TYPE_MUSIC;  

    glib::Object<UnityProtocolPreview> proto_obj(UNITY_PROTOCOL_PREVIEW(unity_protocol_payment_preview_new()));

    unity_protocol_preview_set_title(proto_obj, title.c_str());
    unity_protocol_preview_set_subtitle(proto_obj, subtitle.c_str());
    unity_protocol_preview_add_action(proto_obj, "change_payment_method", "Change payment", NULL, 0);
    unity_protocol_preview_add_action(proto_obj, "forgot_password", "Forgot password", NULL, 0);
    unity_protocol_preview_add_action(proto_obj, "cancel_purchase", "Cancel", NULL, 0);
    unity_protocol_preview_add_action(proto_obj, "purchase_album", "Purchase", NULL, 0);


    unity_protocol_payment_preview_set_header(UNITY_PROTOCOL_PAYMENT_PREVIEW(proto_obj.RawPtr()), header.c_str());
    unity_protocol_payment_preview_set_email(UNITY_PROTOCOL_PAYMENT_PREVIEW(proto_obj.RawPtr()), email.c_str());
    unity_protocol_payment_preview_set_payment_method(UNITY_PROTOCOL_PAYMENT_PREVIEW(proto_obj.RawPtr()), payment_method.c_str());
    unity_protocol_payment_preview_set_purchase_prize(UNITY_PROTOCOL_PAYMENT_PREVIEW(proto_obj.RawPtr()), purchase_prize.c_str());
    unity_protocol_payment_preview_set_purchase_type(UNITY_PROTOCOL_PAYMENT_PREVIEW(proto_obj.RawPtr()), purchase_type.c_str());
    unity_protocol_payment_preview_set_preview_type(UNITY_PROTOCOL_PAYMENT_PREVIEW(proto_obj.RawPtr()), preview_type);

    glib::Variant v(dee_serializable_serialize(DEE_SERIALIZABLE(proto_obj.RawPtr())), glib::StealRef());

    preview_model = dash::Preview::PreviewForVariant(v);
  }

  nux::ObjectPtr<nux::BaseWindow> parent_window_;
  dash::Preview::Ptr preview_model;

  // testing data
  std::string title;
  std::string subtitle;
  std::string header;
  std::string email;
  std::string payment_method;
  std::string purchase_prize;
  std::string purchase_type;
  UnityProtocolPreviewPaymentType preview_type;

  // needed for styles
  previews::Style previews_style;
  dash::Style dash_style;
};

TEST_F(TestMusicPaymentPreview, TestContentLoading)
{
  MockedMusicPaymentPreview::Ptr preview_view(new MockedMusicPaymentPreview(preview_model));

  EXPECT_EQ(preview_view->title_->GetText(), title);
  EXPECT_EQ(preview_view->subtitle_->GetText(), subtitle);
  EXPECT_EQ(preview_view->intro_->GetText(), header);
  EXPECT_EQ(preview_view->email_->GetText(), email);
  EXPECT_EQ(preview_view->payment_->GetText(), payment_method);
  EXPECT_EQ(preview_view->purchase_type_->GetText(), purchase_type);
  EXPECT_EQ(preview_view->purchase_prize_->GetText(), purchase_prize);
}


} // previews

} // dash

} // unity