~libertine-team/libertine-scope/devel

« back to all changes in this revision

Viewing changes to tests/test_preview.cpp

  • Committer: Larry Price
  • Date: 2016-04-18 16:37:49 UTC
  • mfrom: (31.1.12 fix-scope-icon)
  • Revision ID: larry.price@canonical.com-20160418163749-w3a8icvk03b1ho72
Redesign preview pane with reasonably-sized image, title, and description to closer match the store preview.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright 2016 Canonical Ltd.
 
3
 *
 
4
 * This program is free software: you can redistribute it and/or modify it under
 
5
 * the terms of the GNU General Public License, version 3, as published by the
 
6
 * Free Software Foundation.
 
7
 *
 
8
 * This program is distributed in the hope that it will be useful,
 
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
 * GNU General Public License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU General Public License
 
14
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
15
 */
 
16
 
 
17
#include "libertine-scope/preview.h"
 
18
#include <unity/scopes/Variant.h>
 
19
#include <gtest/gtest.h>
 
20
#include <unity/scopes/ActionMetadata.h>
 
21
#include <unity/scopes/testing/Result.h>
 
22
#include <unity/scopes/testing/MockPreviewReply.h>
 
23
#include <unity/scopes/PreviewWidget.h>
 
24
#include <memory>
 
25
#include <QDir>
 
26
 
 
27
 
 
28
TEST(TestPreview, pushesWidgetsWithAppInformation)
 
29
{
 
30
  unity::scopes::testing::Result result;
 
31
  result["desktop_file"] = unity::scopes::Variant(QString("%1/data/Full.desktop").arg(QDir::currentPath()).toStdString());
 
32
  unity::scopes::ActionMetadata metadata("en_US", "phone");
 
33
 
 
34
  std::unique_ptr<unity::scopes::PreviewWidgetList> list(new unity::scopes::PreviewWidgetList());
 
35
        testing::NiceMock<unity::scopes::testing::MockPreviewReply> reply;
 
36
  EXPECT_CALL(reply, push(testing::_)).WillOnce(testing::SaveArg<0>(list.get()));
 
37
  unity::scopes::PreviewReplyProxy proxy(&reply, [](unity::scopes::PreviewReply*) {});
 
38
 
 
39
        Preview preview(result, metadata);
 
40
        preview.run(proxy);
 
41
 
 
42
  ASSERT_NE(nullptr, list);
 
43
  ASSERT_EQ(3, list->size());
 
44
 
 
45
  auto header = list->front();
 
46
  EXPECT_EQ("hdr", header.id());
 
47
  EXPECT_EQ("header", header.widget_type());
 
48
  EXPECT_EQ("title", header.attribute_mappings()["title"]);
 
49
  EXPECT_EQ("art", header.attribute_mappings()["mascot"]);
 
50
 
 
51
  list->pop_front();
 
52
  auto desc = list->front();
 
53
  EXPECT_EQ("desc", desc.id());
 
54
  EXPECT_EQ("This session logs you into Matchbox", desc.attribute_values()["text"].get_string());
 
55
 
 
56
  list->pop_front();
 
57
  auto buttons = list->front();
 
58
  EXPECT_EQ("buttons", buttons.id());
 
59
  EXPECT_EQ("actions", buttons.widget_type());
 
60
  auto buttons_actions = buttons.attribute_values()["actions"].get_array();
 
61
  ASSERT_EQ(1, buttons_actions.size());
 
62
  EXPECT_EQ("open", buttons_actions[0].get_dict()["id"].get_string());
 
63
  EXPECT_EQ("Open", buttons_actions[0].get_dict()["label"].get_string());
 
64
}