~ci-train-bot/keeper/keeper-ubuntu-yakkety-2018

« back to all changes in this revision

Viewing changes to tests/integration/helpers/helpers-test.cc

  • Committer: Bileto Bot
  • Author(s): Xavi Garcia Mena
  • Date: 2016-09-28 13:45:17 UTC
  • mfrom: (112.1.1 keeper)
  • Revision ID: ci-train-bot@canonical.com-20160928134517-bizvaiuve5w933ch
Cancel feature implemented.

Show diffs side-by-side

added added

removed removed

Lines of Context:
127
127
    EXPECT_TRUE(check_storage_framework_files(QStringList{user_dir, user_dir_2}));
128
128
}
129
129
 
 
130
TEST_F(TestHelpers, StartFullTestCancelling)
 
131
{
 
132
    XdgUserDirsSandbox tmp_dir;
 
133
 
 
134
    // starts the services, including keeper-service
 
135
    start_tasks();
 
136
 
 
137
    QSharedPointer<DBusInterfaceKeeperUser> user_iface(new DBusInterfaceKeeperUser(
 
138
                                                            DBusTypes::KEEPER_SERVICE,
 
139
                                                            DBusTypes::KEEPER_USER_PATH,
 
140
                                                            dbus_test_runner.sessionConnection()
 
141
                                                        ) );
 
142
 
 
143
    ASSERT_TRUE(user_iface->isValid()) << qPrintable(dbus_test_runner.sessionConnection().lastError().message());
 
144
 
 
145
    // ask for a list of backup choices
 
146
    QDBusReply<QVariantDictMap> choices = user_iface->call("GetBackupChoices");
 
147
    EXPECT_TRUE(choices.isValid()) << qPrintable(choices.error().message());
 
148
 
 
149
    QString user_option = "XDG_MUSIC_DIR";
 
150
 
 
151
    auto user_dir = qgetenv(user_option.toLatin1().data());
 
152
    ASSERT_FALSE(user_dir.isEmpty());
 
153
    qDebug() << "USER DIR:" << user_dir;
 
154
 
 
155
    // fill something in the music dir
 
156
    FileUtils::fillTemporaryDirectory(user_dir, qrand() % 100);
 
157
 
 
158
    // search for the user folder uuid
 
159
    auto user_folder_uuid = get_uuid_for_xdg_folder_path(user_dir, choices.value());
 
160
    ASSERT_FALSE(user_folder_uuid.isEmpty());
 
161
    qDebug() << "User folder UUID is:" << user_folder_uuid;
 
162
 
 
163
    QString user_option_2 = "XDG_VIDEOS_DIR";
 
164
 
 
165
    auto user_dir_2 = qgetenv(user_option_2.toLatin1().data());
 
166
    ASSERT_FALSE(user_dir_2.isEmpty());
 
167
    qDebug() << "USER DIR 2:" << user_dir_2;
 
168
 
 
169
    // fill something in the music dir
 
170
    FileUtils::fillTemporaryDirectory(user_dir_2, qrand() % 100);
 
171
 
 
172
    // search for the user folder uuid
 
173
    auto user_folder_uuid_2 = get_uuid_for_xdg_folder_path(user_dir_2, choices.value());
 
174
    ASSERT_FALSE(user_folder_uuid_2.isEmpty());
 
175
    qDebug() << "User folder 2 UUID is:" << user_folder_uuid_2;
 
176
 
 
177
    QSharedPointer<DBusPropertiesInterface> properties_interface(new DBusPropertiesInterface(
 
178
                                                            DBusTypes::KEEPER_SERVICE,
 
179
                                                            DBusTypes::KEEPER_USER_PATH,
 
180
                                                            dbus_test_runner.sessionConnection()
 
181
                                                        ) );
 
182
 
 
183
    ASSERT_TRUE(properties_interface->isValid()) << qPrintable(QDBusConnection::sessionBus().lastError().message());
 
184
 
 
185
    QSignalSpy spy(properties_interface.data(),&DBusPropertiesInterface::PropertiesChanged);
 
186
 
 
187
    // Now we know the music folder uuid, let's start the backup for it.
 
188
    QDBusReply<void> backup_reply = user_iface->call("StartBackup", QStringList{user_folder_uuid, user_folder_uuid_2});
 
189
    ASSERT_TRUE(backup_reply.isValid()) << qPrintable(dbus_test_runner.sessionConnection().lastError().message());
 
190
 
 
191
    EXPECT_TRUE(cancel_first_task_at_percentage(spy, 0.20, user_iface));
 
192
 
 
193
    // wait until all the tasks have the action state "complete"
 
194
    // this one uses pooling so it should just call Get once
 
195
    EXPECT_TRUE(wait_for_all_tasks_have_action_state({user_folder_uuid, user_folder_uuid_2}, "cancelled", user_iface));
 
196
 
 
197
    // check that we have no files in storage framework
 
198
    EXPECT_EQ(0, check_storage_framework_nb_files());
 
199
}
 
200
 
130
201
TEST_F(TestHelpers, SimplyCheckThatTheSecondDBusInterfaceIsFine)
131
202
{
132
203
    XdgUserDirsSandbox tmp_dir;