1/* 2 * Copyright (C) 2015, The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17#include <memory> 18#include <string> 19 20#include <gtest/gtest.h> 21 22#include "type_cpp.h" 23 24using std::string; 25using std::unique_ptr; 26 27namespace android { 28namespace aidl { 29namespace cpp { 30 31namespace { 32 33string kParcelableDotName = "Outer.Inner"; 34string kParcelableColonName = "Outer::Inner"; 35 36} // namespace 37 38class CppTypeNamespaceTest : public ::testing::Test { 39 protected: 40 void SetUp() override { 41 types_.Init(); 42 } 43 TypeNamespace types_; 44}; 45 46TEST_F(CppTypeNamespaceTest, HasSomeBasicTypes) { 47 EXPECT_TRUE(types_.HasTypeByCanonicalName("byte")); 48 EXPECT_TRUE(types_.HasTypeByCanonicalName("int")); 49 EXPECT_TRUE(types_.HasTypeByCanonicalName("long")); 50 EXPECT_TRUE(types_.HasTypeByCanonicalName("float")); 51 EXPECT_TRUE(types_.HasTypeByCanonicalName("double")); 52 EXPECT_TRUE(types_.HasTypeByCanonicalName("boolean")); 53 EXPECT_TRUE(types_.HasTypeByCanonicalName("char")); 54 EXPECT_TRUE(types_.HasTypeByCanonicalName("String")); 55} 56 57TEST_F(CppTypeNamespaceTest, SupportsListString) { 58 EXPECT_TRUE( 59 types_.HasTypeByCanonicalName("java.util.List<java.lang.String>")); 60} 61 62TEST_F(CppTypeNamespaceTest, SupportsNestedParcelableClass) { 63 unique_ptr<AidlParcelable> parcelable( 64 new AidlParcelable(new AidlQualifiedName(kParcelableDotName, ""), 65 0, 66 {"a", "goog"})); 67 EXPECT_EQ(parcelable->GetCppName(), kParcelableColonName); 68} 69 70} // namespace cpp 71} // namespace android 72} // namespace aidl 73