| 
									
										
										
										
											2018-01-12 12:29:43 +01:00
										 |  |  | /****************************************************************************
 | 
					
						
							|  |  |  | ** | 
					
						
							|  |  |  | ** Copyright (C) 2018 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.
 | 
					
						
							|  |  |  | ** | 
					
						
							|  |  |  | ****************************************************************************/ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "googletest.h"
 | 
					
						
							|  |  |  | #include "rundocumentparse-utility.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <clangdocument.h>
 | 
					
						
							|  |  |  | #include <clangdocuments.h>
 | 
					
						
							|  |  |  | #include <clangsupport_global.h>
 | 
					
						
							|  |  |  | #include <clangtooltipinfocollector.h>
 | 
					
						
							|  |  |  | #include <clangtranslationunit.h>
 | 
					
						
							|  |  |  | #include <fixitcontainer.h>
 | 
					
						
							|  |  |  | #include <sourcelocationcontainer.h>
 | 
					
						
							|  |  |  | #include <sourcerangecontainer.h>
 | 
					
						
							|  |  |  | #include <unsavedfiles.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <utils/qtcassert.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <clang-c/Index.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | using ::ClangBackEnd::SourceLocationContainer; | 
					
						
							|  |  |  | using ::ClangBackEnd::Document; | 
					
						
							|  |  |  | using ::ClangBackEnd::UnsavedFiles; | 
					
						
							|  |  |  | using ::ClangBackEnd::ToolTipInfo; | 
					
						
							|  |  |  | using ::ClangBackEnd::SourceRangeContainer; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define CHECK_MEMBER(actual, expected, memberName) \
 | 
					
						
							| 
									
										
										
										
											2018-04-04 18:25:23 +02:00
										 |  |  |     if (actual.memberName != expected.memberName) { \ | 
					
						
							|  |  |  |         *result_listener << #memberName " is " + PrintToString(actual.memberName) \ | 
					
						
							|  |  |  |                          << " and not " + PrintToString(expected.memberName); \ | 
					
						
							| 
									
										
										
										
											2018-01-12 12:29:43 +01:00
										 |  |  |         return false; \ | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | MATCHER_P(IsToolTip, expected, std::string(negation ? "isn't" : "is") +  PrintToString(expected)) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     CHECK_MEMBER(arg, expected, text); | 
					
						
							|  |  |  |     CHECK_MEMBER(arg, expected, briefComment); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     CHECK_MEMBER(arg, expected, qdocIdCandidates); | 
					
						
							|  |  |  |     CHECK_MEMBER(arg, expected, qdocMark); | 
					
						
							|  |  |  |     CHECK_MEMBER(arg, expected, qdocCategory); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     CHECK_MEMBER(arg, expected, sizeInBytes); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return true; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | MATCHER_P(IsQdocToolTip, expected, std::string(negation ? "isn't" : "is") +  PrintToString(expected)) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     CHECK_MEMBER(arg, expected, qdocIdCandidates); | 
					
						
							|  |  |  |     CHECK_MEMBER(arg, expected, qdocMark); | 
					
						
							|  |  |  |     CHECK_MEMBER(arg, expected, qdocCategory); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return true; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #undef CHECK_MEMBER
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | struct Data { | 
					
						
							|  |  |  |     ClangBackEnd::UnsavedFiles unsavedFiles; | 
					
						
							| 
									
										
										
										
											2018-09-25 09:41:32 +02:00
										 |  |  |     ClangBackEnd::Documents documents{unsavedFiles}; | 
					
						
							| 
									
										
										
										
											2018-01-12 12:29:43 +01:00
										 |  |  |     Document document{Utf8StringLiteral(TESTDATA_DIR "/tooltipinfo.cpp"), | 
					
						
							| 
									
										
										
										
											2018-09-25 09:41:32 +02:00
										 |  |  |                       {Utf8StringLiteral("-std=c++14")}, | 
					
						
							| 
									
										
										
										
											2018-10-19 10:20:27 +02:00
										 |  |  |                       {}, | 
					
						
							| 
									
										
										
										
											2018-01-12 12:29:43 +01:00
										 |  |  |                       documents}; | 
					
						
							|  |  |  |     UnitTest::RunDocumentParse _1{document}; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class ToolTipInfo : public ::testing::Test | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | protected: | 
					
						
							|  |  |  |     ::ToolTipInfo tooltip(uint line, uint column) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return d->document.translationUnit().tooltip(d->unsavedFiles, | 
					
						
							|  |  |  |                                                      Utf8StringLiteral("UTF-8"), | 
					
						
							|  |  |  |                                                      line, | 
					
						
							|  |  |  |                                                      column); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     static void SetUpTestCase(); | 
					
						
							|  |  |  |     static void TearDownTestCase(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							|  |  |  |     static std::unique_ptr<Data> d; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(ToolTipInfo, LocalVariableInt) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     const ::ToolTipInfo actual = tooltip(3, 5); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(actual, IsToolTip(::ToolTipInfo(Utf8StringLiteral("int")))); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(ToolTipInfo, LocalVariablePointerToConstInt) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     const ::ToolTipInfo actual = tooltip(4, 5); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(actual, IsToolTip(::ToolTipInfo(Utf8StringLiteral("const int *")))); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(ToolTipInfo, LocalParameterVariableConstRefCustomType) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     ::ToolTipInfo expected(Utf8StringLiteral("const Foo &")); | 
					
						
							| 
									
										
										
										
											2018-04-04 18:25:23 +02:00
										 |  |  |     expected.qdocIdCandidates = {Utf8StringLiteral("Foo")}; | 
					
						
							|  |  |  |     expected.qdocMark = Utf8StringLiteral("Foo"); | 
					
						
							|  |  |  |     expected.qdocCategory = ::ToolTipInfo::ClassOrNamespace; | 
					
						
							| 
									
										
										
										
											2018-01-12 12:29:43 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     const ::ToolTipInfo actual = tooltip(12, 12); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(actual, IsToolTip(expected)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(ToolTipInfo, LocalNonParameterVariableConstRefCustomType) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     ::ToolTipInfo expected(Utf8StringLiteral("const Foo")); | 
					
						
							| 
									
										
										
										
											2018-04-04 18:25:23 +02:00
										 |  |  |     expected.qdocIdCandidates = {Utf8StringLiteral("Foo")}; | 
					
						
							|  |  |  |     expected.qdocMark = Utf8StringLiteral("Foo"); | 
					
						
							|  |  |  |     expected.qdocCategory = ::ToolTipInfo::ClassOrNamespace; | 
					
						
							| 
									
										
										
										
											2018-01-12 12:29:43 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     const ::ToolTipInfo actual = tooltip(14, 5); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(actual, IsToolTip(expected)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(ToolTipInfo, MemberVariable) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     const ::ToolTipInfo actual = tooltip(12, 16); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(actual, IsToolTip(::ToolTipInfo(Utf8StringLiteral("int")))); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-04 14:50:10 +02:00
										 |  |  | TEST_F(ToolTipInfo, MemberFunctionCall_QualifiedName) | 
					
						
							| 
									
										
										
										
											2018-01-12 12:29:43 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     const ::ToolTipInfo actual = tooltip(21, 9); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-04 18:25:23 +02:00
										 |  |  |     ASSERT_THAT(actual.text, Utf8StringLiteral("int Bar::mem()")); | 
					
						
							| 
									
										
										
										
											2018-01-12 12:29:43 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // ChangeLog: Show extra specifiers. For functions e.g.: virtual, inline, explicit, const, volatile
 | 
					
						
							| 
									
										
										
										
											2019-04-04 14:50:10 +02:00
										 |  |  | TEST_F(ToolTipInfo, MemberFunctionCall_ExtraSpecifiers) | 
					
						
							| 
									
										
										
										
											2018-01-12 12:29:43 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     const ::ToolTipInfo actual = tooltip(22, 9); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-04 18:25:23 +02:00
										 |  |  |     ASSERT_THAT(actual.text, Utf8StringLiteral("virtual int Bar::virtualConstMem() const")); | 
					
						
							| 
									
										
										
										
											2018-01-12 12:29:43 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(ToolTipInfo, MemberFunctionCall_qdocIdCandidates) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     const ::ToolTipInfo actual = tooltip(21, 9); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-04 18:25:23 +02:00
										 |  |  |     ASSERT_THAT(actual.qdocIdCandidates, ElementsAre(Utf8StringLiteral("Bar::mem"), | 
					
						
							|  |  |  |                                                      Utf8StringLiteral("mem"))); | 
					
						
							| 
									
										
										
										
											2018-01-12 12:29:43 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(ToolTipInfo, MemberFunctionCall_qdocMark_FIXLIBCLANG_CHECKED) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     const ::ToolTipInfo actual = tooltip(21, 9); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-04 18:25:23 +02:00
										 |  |  |     ASSERT_THAT(actual.qdocMark, Utf8StringLiteral("mem()")); | 
					
						
							| 
									
										
										
										
											2018-01-12 12:29:43 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // TODO: Check what is really needed for qdoc before implementing this one.
 | 
					
						
							|  |  |  | TEST_F(ToolTipInfo, DISABLED_MemberFunctionCall_qdocMark_extraSpecifiers) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     const ::ToolTipInfo actual = tooltip(22, 9); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-04 18:25:23 +02:00
										 |  |  |     ASSERT_THAT(actual.qdocMark, Utf8StringLiteral("virtualConstMem() const")); | 
					
						
							| 
									
										
										
										
											2018-01-12 12:29:43 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(ToolTipInfo, MemberFunctionCall_qdocCategory) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     const ::ToolTipInfo actual = tooltip(21, 9); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-04 18:25:23 +02:00
										 |  |  |     ASSERT_THAT(actual.qdocCategory, ::ToolTipInfo::Function); | 
					
						
							| 
									
										
										
										
											2018-01-12 12:29:43 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // TODO: Show the template parameter type, too: "template<typename T>...)"
 | 
					
						
							| 
									
										
										
										
											2019-04-04 14:50:10 +02:00
										 |  |  | TEST_F(ToolTipInfo, TemplateFunctionCall) | 
					
						
							| 
									
										
										
										
											2018-01-12 12:29:43 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     const ::ToolTipInfo actual = tooltip(30, 5); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-04 18:25:23 +02:00
										 |  |  |     ASSERT_THAT(actual.text, Utf8StringLiteral("template<> void t<Foo>(int foo)")); | 
					
						
							| 
									
										
										
										
											2018-01-12 12:29:43 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(ToolTipInfo, TemplateFunctionCall_qdocIdCandidates) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     const ::ToolTipInfo actual = tooltip(30, 5); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-04 18:25:23 +02:00
										 |  |  |     ASSERT_THAT(actual.qdocIdCandidates, ElementsAre(Utf8StringLiteral("t"))); | 
					
						
							| 
									
										
										
										
											2018-01-12 12:29:43 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(ToolTipInfo, TemplateFunctionCall_qdocMark_FIXLIBCLANG_CHECKED) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     const ::ToolTipInfo actual = tooltip(30, 5); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-04 18:25:23 +02:00
										 |  |  |     ASSERT_THAT(actual.qdocMark, Utf8StringLiteral("t(int)")); | 
					
						
							| 
									
										
										
										
											2018-01-12 12:29:43 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(ToolTipInfo, TemplateFunctionCall_qdocCategory) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     const ::ToolTipInfo actual = tooltip(30, 5); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-04 18:25:23 +02:00
										 |  |  |     ASSERT_THAT(actual.qdocCategory, ::ToolTipInfo::Function); | 
					
						
							| 
									
										
										
										
											2018-01-12 12:29:43 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(ToolTipInfo, BriefComment) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     const ::ToolTipInfo actual = tooltip(41, 5); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-04 18:25:23 +02:00
										 |  |  |     ASSERT_THAT(actual.briefComment, Utf8StringLiteral("This is a crazy function.")); | 
					
						
							| 
									
										
										
										
											2018-01-12 12:29:43 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(ToolTipInfo, Enum) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     ::ToolTipInfo expected(Utf8StringLiteral("EnumType")); | 
					
						
							| 
									
										
										
										
											2018-04-04 18:25:23 +02:00
										 |  |  |     expected.qdocIdCandidates = {Utf8StringLiteral("EnumType")}; | 
					
						
							|  |  |  |     expected.qdocMark = Utf8StringLiteral("EnumType"); | 
					
						
							|  |  |  |     expected.qdocCategory = ::ToolTipInfo::Enum; | 
					
						
							| 
									
										
										
										
											2018-01-12 12:29:43 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     const ::ToolTipInfo actual = tooltip(49, 12); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(actual, IsToolTip(expected)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(ToolTipInfo, Enumerator) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     ::ToolTipInfo expected(Utf8StringLiteral("6")); | 
					
						
							| 
									
										
										
										
											2018-04-04 18:25:23 +02:00
										 |  |  |     expected.qdocIdCandidates = {Utf8StringLiteral("Custom")}; | 
					
						
							|  |  |  |     expected.qdocMark = Utf8StringLiteral("EnumType"); | 
					
						
							|  |  |  |     expected.qdocCategory = ::ToolTipInfo::Enum; | 
					
						
							| 
									
										
										
										
											2018-01-12 12:29:43 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     const ::ToolTipInfo actual = tooltip(49, 22); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(actual, IsToolTip(expected)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(ToolTipInfo, TemplateTypeFromParameter) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     ::ToolTipInfo expected(Utf8StringLiteral("const Baz<int> &")); | 
					
						
							| 
									
										
										
										
											2018-04-04 18:25:23 +02:00
										 |  |  |     expected.qdocIdCandidates = {Utf8StringLiteral("Baz")}; | 
					
						
							|  |  |  |     expected.qdocMark = Utf8StringLiteral("Baz"); | 
					
						
							|  |  |  |     expected.qdocCategory = ::ToolTipInfo::ClassOrNamespace; | 
					
						
							| 
									
										
										
										
											2018-01-12 12:29:43 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     const ::ToolTipInfo actual = tooltip(55, 25); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(actual, IsQdocToolTip(expected)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(ToolTipInfo, TemplateTypeFromNonParameter) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     ::ToolTipInfo expected(Utf8StringLiteral("Baz<int>")); | 
					
						
							| 
									
										
										
										
											2018-04-04 18:25:23 +02:00
										 |  |  |     expected.qdocIdCandidates = {Utf8StringLiteral("Baz")}; | 
					
						
							|  |  |  |     expected.qdocMark = Utf8StringLiteral("Baz"); | 
					
						
							|  |  |  |     expected.qdocCategory = ::ToolTipInfo::ClassOrNamespace; | 
					
						
							| 
									
										
										
										
											2018-01-12 12:29:43 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     const ::ToolTipInfo actual = tooltip(56, 19); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(actual, IsToolTip(expected)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(ToolTipInfo, IncludeDirective) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-01-17 14:56:40 +01:00
										 |  |  |     ::ToolTipInfo expected( | 
					
						
							|  |  |  |         QDir::toNativeSeparators(Utf8StringLiteral(TESTDATA_DIR "/tooltipinfo.h"))); | 
					
						
							| 
									
										
										
										
											2018-04-04 18:25:23 +02:00
										 |  |  |     expected.qdocIdCandidates = {Utf8StringLiteral("tooltipinfo.h")}; | 
					
						
							|  |  |  |     expected.qdocMark = Utf8StringLiteral("tooltipinfo.h"); | 
					
						
							|  |  |  |     expected.qdocCategory = ::ToolTipInfo::Brief; | 
					
						
							| 
									
										
										
										
											2018-01-12 12:29:43 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     const ::ToolTipInfo actual = tooltip(59, 11); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(actual, IsToolTip(expected)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(ToolTipInfo, MacroUse_WithMacroFromSameFile) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     const ::ToolTipInfo actual = tooltip(66, 5); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-04 18:25:23 +02:00
										 |  |  |     ASSERT_THAT(actual.text, Utf8StringLiteral("#define MACRO_FROM_MAINFILE(x) x + 3")); | 
					
						
							| 
									
										
										
										
											2018-01-12 12:29:43 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(ToolTipInfo, MacroUse_WithMacroFromHeader) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     const ::ToolTipInfo actual = tooltip(67, 5); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-04 18:25:23 +02:00
										 |  |  |     ASSERT_THAT(actual.text, Utf8StringLiteral("#define MACRO_FROM_HEADER(x) x + \\\n    x + \\\n    x")); | 
					
						
							| 
									
										
										
										
											2018-01-12 12:29:43 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(ToolTipInfo, MacroUse_qdoc) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     ::ToolTipInfo expected; | 
					
						
							| 
									
										
										
										
											2018-04-04 18:25:23 +02:00
										 |  |  |     expected.qdocIdCandidates = {Utf8StringLiteral("MACRO_FROM_MAINFILE")}; | 
					
						
							|  |  |  |     expected.qdocMark = Utf8StringLiteral("MACRO_FROM_MAINFILE"); | 
					
						
							|  |  |  |     expected.qdocCategory = ::ToolTipInfo::Macro; | 
					
						
							| 
									
										
										
										
											2018-01-12 12:29:43 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     const ::ToolTipInfo actual = tooltip(66, 5); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(actual, IsQdocToolTip(expected)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(ToolTipInfo, TypeNameIntroducedByUsingDirectiveIsQualified) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     ::ToolTipInfo expected(Utf8StringLiteral("N::Muu")); | 
					
						
							| 
									
										
										
										
											2018-04-04 18:25:23 +02:00
										 |  |  |     expected.qdocIdCandidates = {Utf8StringLiteral("N::Muu"), Utf8StringLiteral("Muu")}; | 
					
						
							|  |  |  |     expected.qdocMark = Utf8StringLiteral("Muu"); | 
					
						
							|  |  |  |     expected.qdocCategory = ::ToolTipInfo::ClassOrNamespace; | 
					
						
							| 
									
										
										
										
											2018-01-12 12:29:43 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     const ::ToolTipInfo actual = tooltip(77, 5); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(actual, IsToolTip(expected)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(ToolTipInfo, TypeNameIntroducedByUsingDirectiveOfAliasIsResolvedAndQualified) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     ::ToolTipInfo expected(Utf8StringLiteral("N::Muu")); | 
					
						
							| 
									
										
										
										
											2018-04-04 18:25:23 +02:00
										 |  |  |     expected.qdocIdCandidates = {Utf8StringLiteral("N::Muu"), Utf8StringLiteral("Muu")}; | 
					
						
							|  |  |  |     expected.qdocMark = Utf8StringLiteral("Muu"); | 
					
						
							|  |  |  |     expected.qdocCategory = ::ToolTipInfo::ClassOrNamespace; | 
					
						
							| 
									
										
										
										
											2018-01-12 12:29:43 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     const ::ToolTipInfo actual = tooltip(82, 5); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(actual, IsToolTip(expected)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(ToolTipInfo, TypeNameIntroducedByUsingDeclarationIsQualified) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     ::ToolTipInfo expected(Utf8StringLiteral("N::Muu")); | 
					
						
							| 
									
										
										
										
											2018-04-04 18:25:23 +02:00
										 |  |  |     expected.qdocIdCandidates = {Utf8StringLiteral("N::Muu"), Utf8StringLiteral("Muu")}; | 
					
						
							|  |  |  |     expected.qdocMark = Utf8StringLiteral("Muu"); | 
					
						
							|  |  |  |     expected.qdocCategory = ::ToolTipInfo::ClassOrNamespace; | 
					
						
							| 
									
										
										
										
											2018-01-12 12:29:43 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     const ::ToolTipInfo actual = tooltip(87, 5); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(actual, IsToolTip(expected)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(ToolTipInfo, SizeForClassDefinition) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     const ::ToolTipInfo actual = tooltip(92, 8); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-04 18:25:23 +02:00
										 |  |  |     ASSERT_THAT(actual.sizeInBytes, Utf8StringLiteral("2")); | 
					
						
							| 
									
										
										
										
											2018-01-12 12:29:43 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(ToolTipInfo, SizeForMemberField) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     const ::ToolTipInfo actual = tooltip(95, 10); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-04 18:25:23 +02:00
										 |  |  |     ASSERT_THAT(actual.sizeInBytes, Utf8StringLiteral("1")); | 
					
						
							| 
									
										
										
										
											2018-01-12 12:29:43 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(ToolTipInfo, SizeForEnum) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     const ::ToolTipInfo actual = tooltip(97, 12); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-04 18:25:23 +02:00
										 |  |  |     ASSERT_THAT(actual.sizeInBytes, Utf8StringLiteral("4")); | 
					
						
							| 
									
										
										
										
											2018-01-12 12:29:43 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(ToolTipInfo, SizeForUnion) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     const ::ToolTipInfo actual = tooltip(98, 7); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-04 18:25:23 +02:00
										 |  |  |     ASSERT_THAT(actual.sizeInBytes, Utf8StringLiteral("1")); | 
					
						
							| 
									
										
										
										
											2018-01-12 12:29:43 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(ToolTipInfo, Namespace) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     ::ToolTipInfo expected(Utf8StringLiteral("X")); | 
					
						
							| 
									
										
										
										
											2018-04-04 18:25:23 +02:00
										 |  |  |     expected.qdocIdCandidates = {Utf8StringLiteral("X")}; | 
					
						
							|  |  |  |     expected.qdocMark = Utf8StringLiteral("X"); | 
					
						
							|  |  |  |     expected.qdocCategory = ::ToolTipInfo::ClassOrNamespace; | 
					
						
							| 
									
										
										
										
											2018-01-12 12:29:43 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     const ::ToolTipInfo actual = tooltip(106, 11); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(actual, IsToolTip(expected)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(ToolTipInfo, NamespaceQualified) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     ::ToolTipInfo expected(Utf8StringLiteral("X::Y")); | 
					
						
							| 
									
										
										
										
											2018-04-04 18:25:23 +02:00
										 |  |  |     expected.qdocIdCandidates = {Utf8StringLiteral("X::Y"), Utf8StringLiteral("Y")}; | 
					
						
							|  |  |  |     expected.qdocMark = Utf8StringLiteral("Y"); | 
					
						
							|  |  |  |     expected.qdocCategory = ::ToolTipInfo::ClassOrNamespace; | 
					
						
							| 
									
										
										
										
											2018-01-12 12:29:43 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     const ::ToolTipInfo actual = tooltip(107, 11); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(actual, IsToolTip(expected)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // TODO: Show unresolved and resolved name, for F1 try both.
 | 
					
						
							|  |  |  | TEST_F(ToolTipInfo, TypeName_ResolveTypeDef) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     ::ToolTipInfo expected(Utf8StringLiteral("Ptr<Nuu>")); | 
					
						
							| 
									
										
										
										
											2018-04-04 18:25:23 +02:00
										 |  |  |     expected.qdocIdCandidates = {Utf8StringLiteral("PtrFromTypeDef")}; | 
					
						
							|  |  |  |     expected.qdocMark = Utf8StringLiteral("PtrFromTypeDef"); | 
					
						
							|  |  |  |     expected.qdocCategory = ::ToolTipInfo::Typedef; | 
					
						
							| 
									
										
										
										
											2018-01-12 12:29:43 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     const ::ToolTipInfo actual = tooltip(122, 5); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(actual, IsToolTip(expected)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // TODO: Show unresolved and resolved name, for F1 try both.
 | 
					
						
							|  |  |  | TEST_F(ToolTipInfo, TypeName_ResolveAlias) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     ::ToolTipInfo expected(Utf8StringLiteral("Ptr<Nuu>")); | 
					
						
							| 
									
										
										
										
											2018-04-04 18:25:23 +02:00
										 |  |  |     expected.qdocIdCandidates = {Utf8StringLiteral("PtrFromTypeAlias")}; | 
					
						
							|  |  |  |     expected.qdocMark = Utf8StringLiteral("PtrFromTypeAlias"); | 
					
						
							|  |  |  |     expected.qdocCategory = ::ToolTipInfo::Typedef; | 
					
						
							| 
									
										
										
										
											2018-01-12 12:29:43 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     const ::ToolTipInfo actual = tooltip(123, 5); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(actual, IsToolTip(expected)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // The referenced cursor is a CXCursor_TypeAliasTemplateDecl, its type is invalid
 | 
					
						
							|  |  |  | // and so probably clang_getTypedefDeclUnderlyingType() does not return anything useful.
 | 
					
						
							|  |  |  | // TODO: Fix the cursor's type or add new API in libclang for querying the template type alias.
 | 
					
						
							|  |  |  | TEST_F(ToolTipInfo, DISABLED_TypeName_ResolveTemplateTypeAlias) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     const ::ToolTipInfo actual = tooltip(124, 5); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-04 18:25:23 +02:00
										 |  |  |     ASSERT_THAT(actual.text, Utf8StringLiteral("Ptr<Nuu>")); | 
					
						
							| 
									
										
										
										
											2018-01-12 12:29:43 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(ToolTipInfo, TypeName_ResolveTemplateTypeAlias_qdoc) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     ::ToolTipInfo expected; | 
					
						
							| 
									
										
										
										
											2018-04-04 18:25:23 +02:00
										 |  |  |     expected.qdocIdCandidates = {Utf8StringLiteral("PtrFromTemplateTypeAlias")}; | 
					
						
							|  |  |  |     expected.qdocMark = Utf8StringLiteral("PtrFromTemplateTypeAlias"); | 
					
						
							|  |  |  |     expected.qdocCategory = ::ToolTipInfo::Typedef; | 
					
						
							| 
									
										
										
										
											2018-01-12 12:29:43 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     const ::ToolTipInfo actual = tooltip(124, 5); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(actual, IsQdocToolTip(expected)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(ToolTipInfo, TemplateClassReference) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     ::ToolTipInfo expected(Utf8StringLiteral("Zii<T>")); | 
					
						
							| 
									
										
										
										
											2018-04-04 18:25:23 +02:00
										 |  |  |     expected.qdocIdCandidates = {Utf8StringLiteral("Zii")}; | 
					
						
							|  |  |  |     expected.qdocMark = Utf8StringLiteral("Zii"); | 
					
						
							|  |  |  |     expected.qdocCategory = ::ToolTipInfo::ClassOrNamespace; | 
					
						
							| 
									
										
										
										
											2018-01-12 12:29:43 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     const ::ToolTipInfo actual = tooltip(134, 5); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(actual, IsToolTip(expected)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(ToolTipInfo, TemplateClassQualified) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     ::ToolTipInfo expected(Utf8StringLiteral("U::Yii<T>")); | 
					
						
							| 
									
										
										
										
											2018-04-04 18:25:23 +02:00
										 |  |  |     expected.qdocIdCandidates = {Utf8StringLiteral("U::Yii"), Utf8StringLiteral("Yii")}; | 
					
						
							|  |  |  |     expected.qdocMark = Utf8StringLiteral("Yii"); | 
					
						
							|  |  |  |     expected.qdocCategory = ::ToolTipInfo::ClassOrNamespace; | 
					
						
							| 
									
										
										
										
											2018-01-12 12:29:43 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     const ::ToolTipInfo actual = tooltip(135, 5); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(actual, IsToolTip(expected)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(ToolTipInfo, ResolveNamespaceAliasForType) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     ::ToolTipInfo expected(Utf8StringLiteral("A::X")); | 
					
						
							| 
									
										
										
										
											2018-04-04 18:25:23 +02:00
										 |  |  |     expected.qdocIdCandidates = {Utf8StringLiteral("A::X"), Utf8StringLiteral("X")}; | 
					
						
							|  |  |  |     expected.qdocMark = Utf8StringLiteral("X"); | 
					
						
							|  |  |  |     expected.qdocCategory = ::ToolTipInfo::ClassOrNamespace; | 
					
						
							| 
									
										
										
										
											2018-01-12 12:29:43 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     const ::ToolTipInfo actual = tooltip(144, 8); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(actual, IsToolTip(expected)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // TODO: Show unresolved and resolved name, for F1 try both.
 | 
					
						
							|  |  |  | TEST_F(ToolTipInfo, ResolveNamespaceAlias) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     ::ToolTipInfo expected(Utf8StringLiteral("A")); | 
					
						
							| 
									
										
										
										
											2018-04-04 18:25:23 +02:00
										 |  |  |     expected.qdocIdCandidates = {Utf8StringLiteral("B")}; | 
					
						
							|  |  |  |     expected.qdocMark = Utf8StringLiteral("B"); | 
					
						
							|  |  |  |     expected.qdocCategory = ::ToolTipInfo::ClassOrNamespace; | 
					
						
							| 
									
										
										
										
											2018-01-12 12:29:43 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     const ::ToolTipInfo actual = tooltip(144, 5); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(actual, IsToolTip(expected)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(ToolTipInfo, QualificationForTemplateClassInClassInNamespace) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     ::ToolTipInfo expected(Utf8StringLiteral("N::Outer::Inner<int>")); | 
					
						
							| 
									
										
										
										
											2018-04-04 18:25:23 +02:00
										 |  |  |     expected.qdocIdCandidates = {Utf8StringLiteral("N::Outer::Inner"), | 
					
						
							| 
									
										
										
										
											2018-01-12 12:29:43 +01:00
										 |  |  |                                   Utf8StringLiteral("Outer::Inner"), | 
					
						
							| 
									
										
										
										
											2018-04-04 18:25:23 +02:00
										 |  |  |                                   Utf8StringLiteral("Inner")}; | 
					
						
							|  |  |  |     expected.qdocMark = Utf8StringLiteral("Inner"); | 
					
						
							|  |  |  |     expected.qdocCategory = ::ToolTipInfo::ClassOrNamespace; | 
					
						
							|  |  |  |     expected.sizeInBytes = Utf8StringLiteral("1"); | 
					
						
							| 
									
										
										
										
											2018-01-12 12:29:43 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     const ::ToolTipInfo actual = tooltip(153, 16); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(actual, IsToolTip(expected)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(ToolTipInfo, Function) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     ::ToolTipInfo expected(Utf8StringLiteral("void f()")); | 
					
						
							| 
									
										
										
										
											2018-04-04 18:25:23 +02:00
										 |  |  |     expected.qdocIdCandidates = {Utf8StringLiteral("f")}; | 
					
						
							|  |  |  |     expected.qdocMark = Utf8StringLiteral("f()"); | 
					
						
							|  |  |  |     expected.qdocCategory = ::ToolTipInfo::Function; | 
					
						
							| 
									
										
										
										
											2018-01-12 12:29:43 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     const ::ToolTipInfo actual = tooltip(165, 5); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(actual, IsToolTip(expected)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(ToolTipInfo, Function_QualifiedName) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     const ::ToolTipInfo actual = tooltip(166, 8); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-04 18:25:23 +02:00
										 |  |  |     ASSERT_THAT(actual.text, Utf8StringLiteral("void R::f()")); | 
					
						
							| 
									
										
										
										
											2018-01-12 12:29:43 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(ToolTipInfo, Function_qdocIdCandidatesAreQualified) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     const ::ToolTipInfo actual = tooltip(166, 8); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-04 18:25:23 +02:00
										 |  |  |     ASSERT_THAT(actual.qdocIdCandidates, ElementsAre(Utf8StringLiteral("R::f"), | 
					
						
							|  |  |  |                                                      Utf8StringLiteral("f"))); | 
					
						
							| 
									
										
										
										
											2018-01-12 12:29:43 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-04 14:50:10 +02:00
										 |  |  | TEST_F(ToolTipInfo, Function_HasParameterName) | 
					
						
							| 
									
										
										
										
											2018-01-12 12:29:43 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     const ::ToolTipInfo actual = tooltip(167, 5); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-04 18:25:23 +02:00
										 |  |  |     ASSERT_THAT(actual.text, Utf8StringLiteral("void f(int param)")); | 
					
						
							| 
									
										
										
										
											2018-01-12 12:29:43 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // TODO: Implement with CXPrintingPolicy
 | 
					
						
							|  |  |  | TEST_F(ToolTipInfo, DISABLED_Function_HasDefaultArgument) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     const ::ToolTipInfo actual = tooltip(168, 5); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-04 18:25:23 +02:00
										 |  |  |     ASSERT_THAT(actual.text, Utf8StringLiteral("void z(int = 1)")); | 
					
						
							| 
									
										
										
										
											2018-01-12 12:29:43 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(ToolTipInfo, Function_qdocMarkHasNoParameterName) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     const ::ToolTipInfo actual = tooltip(167, 5); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-04 18:25:23 +02:00
										 |  |  |     ASSERT_THAT(actual.qdocMark, Utf8StringLiteral("f(int)")); | 
					
						
							| 
									
										
										
										
											2018-01-12 12:29:43 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(ToolTipInfo, Function_qdocMarkHasNoDefaultArgument) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     const ::ToolTipInfo actual = tooltip(168, 5); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-04 18:25:23 +02:00
										 |  |  |     ASSERT_THAT(actual.qdocMark, Utf8StringLiteral("z(int)")); | 
					
						
							| 
									
										
										
										
											2018-01-12 12:29:43 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST_F(ToolTipInfo, AutoTypeBuiltin) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     const ::ToolTipInfo actual = tooltip(176, 5); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-04 18:25:23 +02:00
										 |  |  |     ASSERT_THAT(actual.text, Utf8StringLiteral("int")); | 
					
						
							| 
									
										
										
										
											2018-01-12 12:29:43 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-04 12:53:04 +01:00
										 |  |  | TEST_F(ToolTipInfo, PointerToPointerToClass) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     ::ToolTipInfo expected(Utf8StringLiteral("Nuu **")); | 
					
						
							|  |  |  |     expected.qdocIdCandidates = {Utf8StringLiteral("Nuu")}; | 
					
						
							|  |  |  |     expected.qdocMark = Utf8StringLiteral("Nuu"); | 
					
						
							|  |  |  |     expected.qdocCategory = ::ToolTipInfo::ClassOrNamespace; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const ::ToolTipInfo actual = tooltip(200, 12); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(actual, IsToolTip(expected)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-12 12:29:43 +01:00
										 |  |  | // TODO: Test for qdoc entries, too.
 | 
					
						
							|  |  |  | TEST_F(ToolTipInfo, AutoTypeEnum) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     const ::ToolTipInfo actual = tooltip(177, 5); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-04 18:25:23 +02:00
										 |  |  |     ASSERT_THAT(actual.text, Utf8StringLiteral("EnumType")); | 
					
						
							| 
									
										
										
										
											2018-01-12 12:29:43 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // TODO: Test for qdoc entries, too.
 | 
					
						
							|  |  |  | TEST_F(ToolTipInfo, AutoTypeClassType) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     const ::ToolTipInfo actual = tooltip(178, 5); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-04 18:25:23 +02:00
										 |  |  |     ASSERT_THAT(actual.text, Utf8StringLiteral("Bar")); | 
					
						
							| 
									
										
										
										
											2018-01-12 12:29:43 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // TODO: Test for qdoc entries, too.
 | 
					
						
							|  |  |  | // TODO: Deduced template arguments work, too?!
 | 
					
						
							|  |  |  | TEST_F(ToolTipInfo, AutoTypeClassTemplateType) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     const ::ToolTipInfo actual = tooltip(179, 5); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-04 18:25:23 +02:00
										 |  |  |     ASSERT_THAT(actual.text, Utf8StringLiteral("Zii<int>")); | 
					
						
							| 
									
										
										
										
											2018-01-12 12:29:43 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-04 14:50:10 +02:00
										 |  |  | TEST_F(ToolTipInfo, Function_DefaultConstructor) | 
					
						
							| 
									
										
										
										
											2018-01-18 16:04:27 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     const ::ToolTipInfo actual = tooltip(193, 5); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-04 18:25:23 +02:00
										 |  |  |     ASSERT_THAT(actual.text, Utf8StringLiteral("inline constexpr Con::Con() noexcept")); | 
					
						
							| 
									
										
										
										
											2018-01-18 16:04:27 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-04 14:50:10 +02:00
										 |  |  | TEST_F(ToolTipInfo, Function_ExplicitDefaultConstructor) | 
					
						
							| 
									
										
										
										
											2018-01-18 16:04:27 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     const ::ToolTipInfo actual = tooltip(194, 5); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-04 18:25:23 +02:00
										 |  |  |     ASSERT_THAT(actual.text, Utf8StringLiteral("ExplicitCon::ExplicitCon() noexcept = default")); | 
					
						
							| 
									
										
										
										
											2018-01-18 16:04:27 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-04 14:50:10 +02:00
										 |  |  | TEST_F(ToolTipInfo, Function_CustomConstructor) | 
					
						
							| 
									
										
										
										
											2018-01-18 16:04:27 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     const ::ToolTipInfo actual = tooltip(195, 5); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-04 18:25:23 +02:00
										 |  |  |     ASSERT_THAT(actual.text, Utf8StringLiteral("ExplicitCon::ExplicitCon(int m)")); | 
					
						
							| 
									
										
										
										
											2018-01-18 16:04:27 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // Overloads are problematic for the help system since the data base has not
 | 
					
						
							|  |  |  | // enough information about them. At least for constructors we can improve
 | 
					
						
							|  |  |  | // the situation a bit - provide a help system query that:
 | 
					
						
							|  |  |  | //   1) will not lead to the replacement of the constructor signature as
 | 
					
						
							|  |  |  | //      clang sees it with the wrong overload documentation
 | 
					
						
							|  |  |  | //      (signature + main help sentence). That's the qdocCategory=Unknown
 | 
					
						
							|  |  |  | //      part.
 | 
					
						
							|  |  |  | //   2) finds the documentation for the class instead of the overload,
 | 
					
						
							|  |  |  | //      so F1 will go to the class documentation.
 | 
					
						
							|  |  |  | TEST_F(ToolTipInfo, Function_ConstructorQDoc) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     ::ToolTipInfo expected; | 
					
						
							| 
									
										
										
										
											2018-04-04 18:25:23 +02:00
										 |  |  |     expected.qdocIdCandidates = {Utf8StringLiteral("Con")}; | 
					
						
							|  |  |  |     expected.qdocMark = Utf8StringLiteral("Con"); | 
					
						
							|  |  |  |     expected.qdocCategory = ::ToolTipInfo::Unknown; | 
					
						
							| 
									
										
										
										
											2018-01-18 16:04:27 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     const ::ToolTipInfo actual = tooltip(193, 5); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ASSERT_THAT(actual, IsQdocToolTip(expected)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-12 12:29:43 +01:00
										 |  |  | std::unique_ptr<Data> ToolTipInfo::d; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void ToolTipInfo::SetUpTestCase() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     d.reset(new Data); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void ToolTipInfo::TearDownTestCase() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     d.reset(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } // anonymous namespace
 |