2015-06-01 18:51:55 +02:00
|
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** Copyright (C) 2015 The Qt Company Ltd.
|
|
|
|
|
** Contact: http://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 Digia. For licensing terms and
|
|
|
|
|
** conditions see http://www.qt.io/licensing. For further information
|
|
|
|
|
** use the contact form at http://www.qt.io/contact-us.
|
|
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
|
|
|
** General Public License version 2.1 or version 3 as published by the Free
|
|
|
|
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
|
|
|
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
|
|
|
|
** following information to ensure the GNU Lesser General Public License
|
|
|
|
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
|
|
|
**
|
|
|
|
|
** In addition, as a special exception, Digia gives you certain additional
|
|
|
|
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
|
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
2015-06-16 12:38:04 +02:00
|
|
|
|
#include "mockipclient.h"
|
2015-06-01 18:51:55 +02:00
|
|
|
|
|
2015-06-16 12:38:04 +02:00
|
|
|
|
#include <clangipcserver.h>
|
2015-06-01 18:51:55 +02:00
|
|
|
|
#include <ipcclientproxy.h>
|
|
|
|
|
#include <ipcserverproxy.h>
|
|
|
|
|
#include <translationunitdoesnotexistexception.h>
|
|
|
|
|
#include <translationunitparseerrorexception.h>
|
|
|
|
|
|
2015-08-19 12:36:43 +02:00
|
|
|
|
#include <cmbcodecompletedmessage.h>
|
|
|
|
|
#include <cmbcompletecodemessage.h>
|
|
|
|
|
#include <cmbechomessage.h>
|
|
|
|
|
#include <cmbregisterprojectsforcodecompletionmessage.h>
|
|
|
|
|
#include <cmbregistertranslationunitsforcodecompletionmessage.h>
|
|
|
|
|
#include <cmbunregisterprojectsforcodecompletionmessage.h>
|
|
|
|
|
#include <cmbunregistertranslationunitsforcodecompletionmessage.h>
|
2015-08-31 16:28:26 +02:00
|
|
|
|
#include <diagnosticschangedmessage.h>
|
2015-08-19 12:36:43 +02:00
|
|
|
|
#include <projectpartsdonotexistmessage.h>
|
|
|
|
|
#include <translationunitdoesnotexistmessage.h>
|
2015-06-01 18:51:55 +02:00
|
|
|
|
|
|
|
|
|
#include <QBuffer>
|
|
|
|
|
#include <QFile>
|
|
|
|
|
|
2015-06-16 12:38:04 +02:00
|
|
|
|
#include <gmock/gmock.h>
|
|
|
|
|
#include <gmock/gmock-matchers.h>
|
|
|
|
|
#include <gtest/gtest.h>
|
2015-07-01 14:50:35 +02:00
|
|
|
|
#include "gtest-qt-printing.h"
|
2015-06-01 18:51:55 +02:00
|
|
|
|
|
|
|
|
|
using testing::Property;
|
|
|
|
|
using testing::Contains;
|
|
|
|
|
using testing::Not;
|
|
|
|
|
using testing::Eq;
|
|
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
2015-08-19 12:36:43 +02:00
|
|
|
|
using ClangBackEnd::RegisterTranslationUnitForCodeCompletionMessage;
|
|
|
|
|
using ClangBackEnd::UnregisterTranslationUnitsForCodeCompletionMessage;
|
|
|
|
|
using ClangBackEnd::RegisterProjectPartsForCodeCompletionMessage;
|
|
|
|
|
using ClangBackEnd::UnregisterProjectPartsForCodeCompletionMessage;
|
|
|
|
|
using ClangBackEnd::CompleteCodeMessage;
|
|
|
|
|
using ClangBackEnd::CodeCompletedMessage;
|
2015-06-16 11:56:00 +02:00
|
|
|
|
using ClangBackEnd::CodeCompletion;
|
|
|
|
|
using ClangBackEnd::FileContainer;
|
|
|
|
|
using ClangBackEnd::ProjectPartContainer;
|
2015-08-19 12:36:43 +02:00
|
|
|
|
using ClangBackEnd::TranslationUnitDoesNotExistMessage;
|
|
|
|
|
using ClangBackEnd::ProjectPartsDoNotExistMessage;
|
2015-06-01 18:51:55 +02:00
|
|
|
|
|
|
|
|
|
class ClangIpcServer : public ::testing::Test
|
|
|
|
|
{
|
|
|
|
|
protected:
|
|
|
|
|
void SetUp() override;
|
|
|
|
|
|
|
|
|
|
void registerFiles();
|
|
|
|
|
void registerProjectPart();
|
|
|
|
|
void changeProjectPartArguments();
|
|
|
|
|
void changeProjectPartArgumentsToWrongValues();
|
|
|
|
|
static const Utf8String unsavedContent(const QString &unsavedFilePath);
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
MockIpcClient mockIpcClient;
|
2015-06-16 11:56:00 +02:00
|
|
|
|
ClangBackEnd::ClangIpcServer clangServer;
|
2015-06-01 18:51:55 +02:00
|
|
|
|
const Utf8String projectPartId = Utf8StringLiteral("pathToProjectPart.pro");
|
|
|
|
|
const Utf8String functionTestFilePath = Utf8StringLiteral(TESTDATA_DIR"/complete_extractor_function.cpp");
|
|
|
|
|
const Utf8String variableTestFilePath = Utf8StringLiteral(TESTDATA_DIR"/complete_extractor_variable.cpp");
|
|
|
|
|
const QString unsavedTestFilePath = QStringLiteral(TESTDATA_DIR) + QStringLiteral("/complete_extractor_function_unsaved.cpp");
|
|
|
|
|
const QString updatedUnsavedTestFilePath = QStringLiteral(TESTDATA_DIR) + QStringLiteral("/complete_extractor_function_unsaved_2.cpp");
|
|
|
|
|
const Utf8String parseErrorTestFilePath = Utf8StringLiteral(TESTDATA_DIR"/complete_translationunit_parse_error.cpp");
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ClangIpcServer::SetUp()
|
|
|
|
|
{
|
|
|
|
|
clangServer.addClient(&mockIpcClient);
|
|
|
|
|
registerProjectPart();
|
|
|
|
|
registerFiles();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ClangIpcServer::registerFiles()
|
|
|
|
|
{
|
2015-08-19 12:36:43 +02:00
|
|
|
|
RegisterTranslationUnitForCodeCompletionMessage message({FileContainer(functionTestFilePath, projectPartId, unsavedContent(unsavedTestFilePath), true),
|
2015-06-01 18:51:55 +02:00
|
|
|
|
FileContainer(variableTestFilePath, projectPartId)});
|
|
|
|
|
|
2015-08-19 12:36:43 +02:00
|
|
|
|
clangServer.registerTranslationUnitsForCodeCompletion(message);
|
2015-06-01 18:51:55 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ClangIpcServer::registerProjectPart()
|
|
|
|
|
{
|
2015-08-19 12:36:43 +02:00
|
|
|
|
RegisterProjectPartsForCodeCompletionMessage message({ProjectPartContainer(projectPartId)});
|
2015-06-01 18:51:55 +02:00
|
|
|
|
|
2015-08-19 12:36:43 +02:00
|
|
|
|
clangServer.registerProjectPartsForCodeCompletion(message);
|
2015-06-01 18:51:55 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ClangIpcServer::changeProjectPartArguments()
|
|
|
|
|
{
|
2015-08-19 12:36:43 +02:00
|
|
|
|
RegisterProjectPartsForCodeCompletionMessage message({ProjectPartContainer(projectPartId, {Utf8StringLiteral("-DArgumentDefinition")})});
|
2015-06-01 18:51:55 +02:00
|
|
|
|
|
2015-08-19 12:36:43 +02:00
|
|
|
|
clangServer.registerProjectPartsForCodeCompletion(message);
|
2015-06-01 18:51:55 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ClangIpcServer::changeProjectPartArgumentsToWrongValues()
|
|
|
|
|
{
|
2015-08-19 12:36:43 +02:00
|
|
|
|
RegisterProjectPartsForCodeCompletionMessage message({ProjectPartContainer(projectPartId, {Utf8StringLiteral("-blah")})});
|
2015-06-01 18:51:55 +02:00
|
|
|
|
|
2015-08-19 12:36:43 +02:00
|
|
|
|
clangServer.registerProjectPartsForCodeCompletion(message);
|
2015-06-01 18:51:55 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const Utf8String ClangIpcServer::unsavedContent(const QString &unsavedFilePath)
|
|
|
|
|
{
|
|
|
|
|
QFile unsavedFileContentFile(unsavedFilePath);
|
|
|
|
|
bool isOpen = unsavedFileContentFile.open(QIODevice::ReadOnly | QIODevice::Text);
|
|
|
|
|
if (!isOpen)
|
|
|
|
|
ADD_FAILURE() << "File with the unsaved content cannot be opened!";
|
|
|
|
|
|
|
|
|
|
return Utf8String::fromByteArray(unsavedFileContentFile.readAll());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(ClangIpcServer, GetCodeCompletion)
|
|
|
|
|
{
|
2015-08-19 12:36:43 +02:00
|
|
|
|
CompleteCodeMessage completeCodeMessage(functionTestFilePath,
|
2015-06-01 18:51:55 +02:00
|
|
|
|
20,
|
|
|
|
|
1,
|
|
|
|
|
projectPartId);
|
|
|
|
|
CodeCompletion codeCompletion(Utf8StringLiteral("Function"),
|
|
|
|
|
34,
|
|
|
|
|
CodeCompletion::FunctionCompletionKind);
|
|
|
|
|
|
2015-08-19 12:36:43 +02:00
|
|
|
|
EXPECT_CALL(mockIpcClient, codeCompleted(Property(&CodeCompletedMessage::codeCompletions, Contains(codeCompletion))))
|
2015-06-01 18:51:55 +02:00
|
|
|
|
.Times(1);
|
|
|
|
|
|
2015-08-19 12:36:43 +02:00
|
|
|
|
clangServer.completeCode(completeCodeMessage);
|
2015-06-01 18:51:55 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(ClangIpcServer, GetCodeCompletionDependingOnArgumets)
|
|
|
|
|
{
|
2015-08-19 12:36:43 +02:00
|
|
|
|
CompleteCodeMessage completeCodeMessage(variableTestFilePath,
|
2015-06-01 18:51:55 +02:00
|
|
|
|
35,
|
|
|
|
|
1,
|
|
|
|
|
projectPartId);
|
|
|
|
|
CodeCompletion codeCompletion(Utf8StringLiteral("ArgumentDefinitionVariable"),
|
|
|
|
|
34,
|
|
|
|
|
CodeCompletion::VariableCompletionKind);
|
|
|
|
|
|
2015-08-19 12:36:43 +02:00
|
|
|
|
EXPECT_CALL(mockIpcClient, codeCompleted(Property(&CodeCompletedMessage::codeCompletions, Contains(codeCompletion))))
|
2015-06-01 18:51:55 +02:00
|
|
|
|
.Times(1);
|
|
|
|
|
|
|
|
|
|
changeProjectPartArguments();
|
2015-08-19 12:36:43 +02:00
|
|
|
|
clangServer.completeCode(completeCodeMessage);
|
2015-06-01 18:51:55 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(ClangIpcServer, GetTranslationUnitDoesNotExistForCodeCompletionOnNonExistingTranslationUnit)
|
|
|
|
|
{
|
2015-08-19 12:36:43 +02:00
|
|
|
|
CompleteCodeMessage completeCodeMessage(Utf8StringLiteral("dontexists.cpp"),
|
2015-06-01 18:51:55 +02:00
|
|
|
|
34,
|
|
|
|
|
1,
|
|
|
|
|
projectPartId);
|
2015-08-19 12:36:43 +02:00
|
|
|
|
TranslationUnitDoesNotExistMessage translationUnitDoesNotExistMessage(Utf8StringLiteral("dontexists.cpp"), projectPartId);
|
2015-06-01 18:51:55 +02:00
|
|
|
|
|
2015-08-19 12:36:43 +02:00
|
|
|
|
EXPECT_CALL(mockIpcClient, translationUnitDoesNotExist(translationUnitDoesNotExistMessage))
|
2015-06-01 18:51:55 +02:00
|
|
|
|
.Times(1);
|
|
|
|
|
|
2015-08-19 12:36:43 +02:00
|
|
|
|
clangServer.completeCode(completeCodeMessage);
|
2015-06-01 18:51:55 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(ClangIpcServer, GetTranslationUnitDoesNotExistForCompletingUnregisteredFile)
|
|
|
|
|
{
|
2015-08-19 12:36:43 +02:00
|
|
|
|
CompleteCodeMessage completeCodeMessage(parseErrorTestFilePath,
|
2015-06-01 18:51:55 +02:00
|
|
|
|
20,
|
|
|
|
|
1,
|
|
|
|
|
projectPartId);
|
2015-08-19 12:36:43 +02:00
|
|
|
|
TranslationUnitDoesNotExistMessage translationUnitDoesNotExistMessage(parseErrorTestFilePath, projectPartId);
|
2015-06-01 18:51:55 +02:00
|
|
|
|
|
2015-08-19 12:36:43 +02:00
|
|
|
|
EXPECT_CALL(mockIpcClient, translationUnitDoesNotExist(translationUnitDoesNotExistMessage))
|
2015-06-01 18:51:55 +02:00
|
|
|
|
.Times(1);
|
|
|
|
|
|
2015-08-19 12:36:43 +02:00
|
|
|
|
clangServer.completeCode(completeCodeMessage);
|
2015-06-01 18:51:55 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(ClangIpcServer, GetCodeCompletionForUnsavedFile)
|
|
|
|
|
{
|
2015-08-19 12:36:43 +02:00
|
|
|
|
CompleteCodeMessage completeCodeMessage(functionTestFilePath,
|
2015-06-01 18:51:55 +02:00
|
|
|
|
20,
|
|
|
|
|
1,
|
|
|
|
|
projectPartId);
|
|
|
|
|
CodeCompletion codeCompletion(Utf8StringLiteral("Method2"),
|
|
|
|
|
34,
|
|
|
|
|
CodeCompletion::FunctionCompletionKind);
|
|
|
|
|
|
2015-08-19 12:36:43 +02:00
|
|
|
|
EXPECT_CALL(mockIpcClient, codeCompleted(Property(&CodeCompletedMessage::codeCompletions, Contains(codeCompletion))))
|
2015-06-01 18:51:55 +02:00
|
|
|
|
.Times(1);
|
|
|
|
|
|
2015-08-19 12:36:43 +02:00
|
|
|
|
clangServer.completeCode(completeCodeMessage);
|
2015-06-01 18:51:55 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(ClangIpcServer, GetNoCodeCompletionAfterRemovingUnsavedFile)
|
|
|
|
|
{
|
2015-08-31 12:40:14 +02:00
|
|
|
|
clangServer.registerTranslationUnitsForCodeCompletion(RegisterTranslationUnitForCodeCompletionMessage({FileContainer(functionTestFilePath, projectPartId, 74)}));
|
2015-08-19 12:36:43 +02:00
|
|
|
|
CompleteCodeMessage completeCodeMessage(functionTestFilePath,
|
2015-06-01 18:51:55 +02:00
|
|
|
|
20,
|
|
|
|
|
1,
|
|
|
|
|
projectPartId);
|
|
|
|
|
CodeCompletion codeCompletion(Utf8StringLiteral("Method2"),
|
|
|
|
|
34,
|
|
|
|
|
CodeCompletion::FunctionCompletionKind);
|
|
|
|
|
|
2015-08-19 12:36:43 +02:00
|
|
|
|
EXPECT_CALL(mockIpcClient, codeCompleted(Property(&CodeCompletedMessage::codeCompletions, Not(Contains(codeCompletion)))))
|
2015-06-01 18:51:55 +02:00
|
|
|
|
.Times(1);
|
|
|
|
|
|
2015-08-19 12:36:43 +02:00
|
|
|
|
clangServer.completeCode(completeCodeMessage);
|
2015-06-01 18:51:55 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(ClangIpcServer, GetNewCodeCompletionAfterUpdatingUnsavedFile)
|
|
|
|
|
{
|
2015-08-19 12:36:43 +02:00
|
|
|
|
clangServer.registerTranslationUnitsForCodeCompletion(RegisterTranslationUnitForCodeCompletionMessage({FileContainer(functionTestFilePath,
|
2015-06-01 18:51:55 +02:00
|
|
|
|
projectPartId,
|
|
|
|
|
unsavedContent(updatedUnsavedTestFilePath),
|
2015-08-31 12:40:14 +02:00
|
|
|
|
true,
|
|
|
|
|
74)}));
|
2015-08-19 12:36:43 +02:00
|
|
|
|
CompleteCodeMessage completeCodeMessage(functionTestFilePath,
|
2015-06-01 18:51:55 +02:00
|
|
|
|
20,
|
|
|
|
|
1,
|
|
|
|
|
projectPartId);
|
|
|
|
|
CodeCompletion codeCompletion(Utf8StringLiteral("Method3"),
|
|
|
|
|
34,
|
|
|
|
|
CodeCompletion::FunctionCompletionKind);
|
|
|
|
|
|
2015-08-19 12:36:43 +02:00
|
|
|
|
EXPECT_CALL(mockIpcClient, codeCompleted(Property(&CodeCompletedMessage::codeCompletions, Contains(codeCompletion))))
|
2015-06-01 18:51:55 +02:00
|
|
|
|
.Times(1);
|
|
|
|
|
|
2015-08-19 12:36:43 +02:00
|
|
|
|
clangServer.completeCode(completeCodeMessage);
|
2015-06-01 18:51:55 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(ClangIpcServer, GetTranslationUnitDoesNotExistForUnregisterTranslationUnitWithWrongFilePath)
|
|
|
|
|
{
|
|
|
|
|
FileContainer fileContainer(Utf8StringLiteral("foo.cpp"), projectPartId);
|
2015-08-19 12:36:43 +02:00
|
|
|
|
UnregisterTranslationUnitsForCodeCompletionMessage message({fileContainer});
|
|
|
|
|
TranslationUnitDoesNotExistMessage translationUnitDoesNotExistMessage(fileContainer);
|
2015-06-01 18:51:55 +02:00
|
|
|
|
|
2015-08-19 12:36:43 +02:00
|
|
|
|
EXPECT_CALL(mockIpcClient, translationUnitDoesNotExist(translationUnitDoesNotExistMessage))
|
2015-06-01 18:51:55 +02:00
|
|
|
|
.Times(1);
|
|
|
|
|
|
2015-08-19 12:36:43 +02:00
|
|
|
|
clangServer.unregisterTranslationUnitsForCodeCompletion(message);
|
2015-06-01 18:51:55 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(ClangIpcServer, UnregisterTranslationUnitAndTestFailingCompletion)
|
|
|
|
|
{
|
|
|
|
|
FileContainer fileContainer(functionTestFilePath, projectPartId);
|
2015-08-19 12:36:43 +02:00
|
|
|
|
UnregisterTranslationUnitsForCodeCompletionMessage message({fileContainer});
|
|
|
|
|
clangServer.unregisterTranslationUnitsForCodeCompletion(message);
|
|
|
|
|
CompleteCodeMessage completeCodeMessage(functionTestFilePath,
|
2015-06-01 18:51:55 +02:00
|
|
|
|
20,
|
|
|
|
|
1,
|
|
|
|
|
projectPartId);
|
2015-08-19 12:36:43 +02:00
|
|
|
|
TranslationUnitDoesNotExistMessage translationUnitDoesNotExistMessage(fileContainer);
|
2015-06-01 18:51:55 +02:00
|
|
|
|
|
2015-08-19 12:36:43 +02:00
|
|
|
|
EXPECT_CALL(mockIpcClient, translationUnitDoesNotExist(translationUnitDoesNotExistMessage))
|
2015-06-01 18:51:55 +02:00
|
|
|
|
.Times(1);
|
|
|
|
|
|
2015-08-19 12:36:43 +02:00
|
|
|
|
clangServer.completeCode(completeCodeMessage);
|
2015-06-01 18:51:55 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(ClangIpcServer, GetProjectPartDoesNotExistUnregisterProjectPartInexistingProjectPart)
|
|
|
|
|
{
|
|
|
|
|
Utf8StringVector inexistingProjectPartFilePath = {Utf8StringLiteral("projectpartsdoesnotexist.pro"), Utf8StringLiteral("project2doesnotexists.pro")};
|
2015-08-19 12:36:43 +02:00
|
|
|
|
UnregisterProjectPartsForCodeCompletionMessage unregisterProjectPartsForCodeCompletionMessage(inexistingProjectPartFilePath);
|
|
|
|
|
ProjectPartsDoNotExistMessage projectPartsDoNotExistMessage(inexistingProjectPartFilePath);
|
2015-06-01 18:51:55 +02:00
|
|
|
|
|
2015-08-19 12:36:43 +02:00
|
|
|
|
EXPECT_CALL(mockIpcClient, projectPartsDoNotExist(projectPartsDoNotExistMessage))
|
2015-06-01 18:51:55 +02:00
|
|
|
|
.Times(1);
|
|
|
|
|
|
2015-08-19 12:36:43 +02:00
|
|
|
|
clangServer.unregisterProjectPartsForCodeCompletion(unregisterProjectPartsForCodeCompletionMessage);
|
2015-06-01 18:51:55 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(ClangIpcServer, GetProjectPartDoesNotExistRegisterTranslationUnitWithInexistingProjectPart)
|
|
|
|
|
{
|
|
|
|
|
Utf8String inexistingProjectPartFilePath = Utf8StringLiteral("projectpartsdoesnotexist.pro");
|
2015-08-19 12:36:43 +02:00
|
|
|
|
RegisterTranslationUnitForCodeCompletionMessage registerFileForCodeCompletionMessage({FileContainer(variableTestFilePath, inexistingProjectPartFilePath)});
|
|
|
|
|
ProjectPartsDoNotExistMessage projectPartsDoNotExistMessage({inexistingProjectPartFilePath});
|
2015-06-01 18:51:55 +02:00
|
|
|
|
|
2015-08-19 12:36:43 +02:00
|
|
|
|
EXPECT_CALL(mockIpcClient, projectPartsDoNotExist(projectPartsDoNotExistMessage))
|
2015-06-01 18:51:55 +02:00
|
|
|
|
.Times(1);
|
|
|
|
|
|
2015-08-19 12:36:43 +02:00
|
|
|
|
clangServer.registerTranslationUnitsForCodeCompletion(registerFileForCodeCompletionMessage);
|
2015-06-01 18:51:55 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(ClangIpcServer, GetProjectPartDoesNotExistUnregisterTranslationUnitWithInexistingProjectPart)
|
|
|
|
|
{
|
|
|
|
|
Utf8String inexistingProjectPartFilePath = Utf8StringLiteral("projectpartsdoesnotexist.pro");
|
2015-08-19 12:36:43 +02:00
|
|
|
|
UnregisterTranslationUnitsForCodeCompletionMessage unregisterFileForCodeCompletionMessage({FileContainer(variableTestFilePath, inexistingProjectPartFilePath)});
|
|
|
|
|
ProjectPartsDoNotExistMessage projectPartsDoNotExistMessage({inexistingProjectPartFilePath});
|
2015-06-01 18:51:55 +02:00
|
|
|
|
|
2015-08-19 12:36:43 +02:00
|
|
|
|
EXPECT_CALL(mockIpcClient, projectPartsDoNotExist(projectPartsDoNotExistMessage))
|
2015-06-01 18:51:55 +02:00
|
|
|
|
.Times(1);
|
|
|
|
|
|
2015-08-19 12:36:43 +02:00
|
|
|
|
clangServer.unregisterTranslationUnitsForCodeCompletion(unregisterFileForCodeCompletionMessage);
|
2015-06-01 18:51:55 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(ClangIpcServer, GetProjectPartDoesNotExistForCompletingProjectPartFile)
|
|
|
|
|
{
|
|
|
|
|
Utf8String inexistingProjectPartFilePath = Utf8StringLiteral("projectpartsdoesnotexist.pro");
|
2015-08-19 12:36:43 +02:00
|
|
|
|
CompleteCodeMessage completeCodeMessage(variableTestFilePath,
|
2015-06-01 18:51:55 +02:00
|
|
|
|
20,
|
|
|
|
|
1,
|
|
|
|
|
inexistingProjectPartFilePath);
|
2015-08-19 12:36:43 +02:00
|
|
|
|
ProjectPartsDoNotExistMessage projectPartsDoNotExistMessage({inexistingProjectPartFilePath});
|
2015-06-01 18:51:55 +02:00
|
|
|
|
|
2015-08-19 12:36:43 +02:00
|
|
|
|
EXPECT_CALL(mockIpcClient, projectPartsDoNotExist(projectPartsDoNotExistMessage))
|
2015-06-01 18:51:55 +02:00
|
|
|
|
.Times(1);
|
|
|
|
|
|
2015-08-19 12:36:43 +02:00
|
|
|
|
clangServer.completeCode(completeCodeMessage);
|
2015-06-01 18:51:55 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(ClangIpcServer, GetProjectPartDoesNotExistForCompletingUnregisteredFile)
|
|
|
|
|
{
|
2015-08-19 12:36:43 +02:00
|
|
|
|
CompleteCodeMessage completeCodeMessage(parseErrorTestFilePath,
|
2015-06-01 18:51:55 +02:00
|
|
|
|
20,
|
|
|
|
|
1,
|
|
|
|
|
projectPartId);
|
2015-08-19 12:36:43 +02:00
|
|
|
|
TranslationUnitDoesNotExistMessage translationUnitDoesNotExistMessage(parseErrorTestFilePath, projectPartId);
|
2015-06-01 18:51:55 +02:00
|
|
|
|
|
2015-08-19 12:36:43 +02:00
|
|
|
|
EXPECT_CALL(mockIpcClient, translationUnitDoesNotExist(translationUnitDoesNotExistMessage))
|
2015-06-01 18:51:55 +02:00
|
|
|
|
.Times(1);
|
|
|
|
|
|
2015-08-19 12:36:43 +02:00
|
|
|
|
clangServer.completeCode(completeCodeMessage);
|
2015-06-01 18:51:55 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(ClangIpcServer, TicketNumberIsForwarded)
|
|
|
|
|
{
|
2015-08-19 12:36:43 +02:00
|
|
|
|
CompleteCodeMessage completeCodeMessage(functionTestFilePath,
|
2015-06-01 18:51:55 +02:00
|
|
|
|
20,
|
|
|
|
|
1,
|
|
|
|
|
projectPartId);
|
|
|
|
|
CodeCompletion codeCompletion(Utf8StringLiteral("Function"),
|
|
|
|
|
34,
|
|
|
|
|
CodeCompletion::FunctionCompletionKind);
|
|
|
|
|
|
2015-08-19 12:36:43 +02:00
|
|
|
|
EXPECT_CALL(mockIpcClient, codeCompleted(Property(&CodeCompletedMessage::ticketNumber, Eq(completeCodeMessage.ticketNumber()))))
|
2015-06-01 18:51:55 +02:00
|
|
|
|
.Times(1);
|
|
|
|
|
|
2015-08-19 12:36:43 +02:00
|
|
|
|
clangServer.completeCode(completeCodeMessage);
|
2015-06-01 18:51:55 +02:00
|
|
|
|
}
|
|
|
|
|
}
|