2016-05-31 16:07:09 +02:00
|
|
|
/****************************************************************************
|
|
|
|
**
|
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
|
|
|
**
|
|
|
|
** This file is part of Qt Creator.
|
|
|
|
**
|
|
|
|
** Commercial License Usage
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
|
|
|
**
|
|
|
|
** GNU General Public License Usage
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
|
|
|
**
|
|
|
|
****************************************************************************/
|
|
|
|
|
2016-09-15 17:41:41 +02:00
|
|
|
#include "clangasyncjob-base.h"
|
2016-05-31 16:07:09 +02:00
|
|
|
|
2018-05-31 15:21:53 +02:00
|
|
|
#include <clangrequestannotationsjob.h>
|
2016-05-31 16:07:09 +02:00
|
|
|
|
|
|
|
using namespace ClangBackEnd;
|
|
|
|
|
|
|
|
using testing::_;
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
2018-05-31 15:21:53 +02:00
|
|
|
class RequestAnnotationsJob : public ClangAsyncJobTest
|
2016-05-31 16:07:09 +02:00
|
|
|
{
|
|
|
|
protected:
|
2018-05-31 15:21:53 +02:00
|
|
|
void SetUp() override { BaseSetUp(JobRequest::Type::RequestAnnotations, job); }
|
2016-05-31 16:07:09 +02:00
|
|
|
|
|
|
|
protected:
|
2018-05-31 15:21:53 +02:00
|
|
|
ClangBackEnd::RequestAnnotationsJob job;
|
2016-05-31 16:07:09 +02:00
|
|
|
};
|
|
|
|
|
2018-05-31 15:21:53 +02:00
|
|
|
TEST_F(RequestAnnotationsJob, PrepareAsyncRun)
|
2016-05-31 16:07:09 +02:00
|
|
|
{
|
|
|
|
job.setContext(jobContext);
|
|
|
|
|
|
|
|
ASSERT_TRUE(job.prepareAsyncRun());
|
|
|
|
}
|
|
|
|
|
2018-05-31 15:21:53 +02:00
|
|
|
TEST_F(RequestAnnotationsJob, RunAsync)
|
2016-05-31 16:07:09 +02:00
|
|
|
{
|
|
|
|
job.setContext(jobContext);
|
|
|
|
job.prepareAsyncRun();
|
|
|
|
|
|
|
|
job.runAsync();
|
|
|
|
|
|
|
|
ASSERT_TRUE(waitUntilJobFinished(job));
|
|
|
|
}
|
|
|
|
|
2018-05-31 15:21:53 +02:00
|
|
|
TEST_F(RequestAnnotationsJob, SendAnnotations)
|
2016-05-31 16:07:09 +02:00
|
|
|
{
|
|
|
|
job.setContext(jobContextWithMockClient);
|
|
|
|
job.prepareAsyncRun();
|
2018-05-31 15:21:53 +02:00
|
|
|
EXPECT_CALL(mockIpcClient, annotations(_)).Times(1);
|
2016-05-31 16:07:09 +02:00
|
|
|
|
|
|
|
job.runAsync();
|
|
|
|
|
|
|
|
ASSERT_TRUE(waitUntilJobFinished(job));
|
|
|
|
}
|
|
|
|
|
2018-05-31 15:21:53 +02:00
|
|
|
TEST_F(RequestAnnotationsJob, DontSendAnnotationsIfDocumentWasClosed)
|
2016-05-31 16:07:09 +02:00
|
|
|
{
|
|
|
|
job.setContext(jobContextWithMockClient);
|
|
|
|
job.prepareAsyncRun();
|
2018-05-31 15:21:53 +02:00
|
|
|
EXPECT_CALL(mockIpcClient, annotations(_)).Times(0);
|
2016-05-31 16:07:09 +02:00
|
|
|
|
|
|
|
job.runAsync();
|
2018-09-25 09:41:32 +02:00
|
|
|
documents.remove({FileContainer{filePath}});
|
2016-05-31 16:07:09 +02:00
|
|
|
|
|
|
|
ASSERT_TRUE(waitUntilJobFinished(job));
|
|
|
|
}
|
|
|
|
|
|
|
|
} // anonymous
|