1/* 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16#include <gtest/gtest.h> 17#include "cacheable_idl.h" 18#include "cacheable_common.h" 19#include "util/options.h" 20#include "parser/parser.h" 21 22using namespace testing; 23using namespace testing::ext; 24namespace OHOS { 25namespace Idl { 26using namespace TestCommon; 27 28class CacheableTest : public testing::Test { 29public: 30 CacheableTest() {} 31 32 virtual ~CacheableTest() {} 33 34 static void SetUpTestCase(); 35 36 static void TearDownTestCase(); 37 38 void SetUp(); 39 40 void TearDown(); 41}; 42 43void CacheableTest::SetUpTestCase() {} 44 45void CacheableTest::TearDownTestCase() {} 46 47void CacheableTest::SetUp() {} 48 49void CacheableTest::TearDown() {} 50 51/* 52 * @tc.name: CacheTimeTest001 53 * @tc.desc: test CacheTime 54 * @tc.type: FUNC 55 * @tc.require: 56 */ 57HWTEST_F(CacheableTest, CacheTimeTest001, Function | MediumTest | Level1) 58{ 59 GTEST_LOG_(INFO) << "CacheableTest, CacheTimeTest_0100, TestSize.Level1"; 60 61 PrepareIdlFile(CACHE_TIME_001_IDL_NAME.c_str(), 62 CACHEABLE_TIME_TEST001_IDL_CONTENT.c_str()); 63 64 const char* argvArray[] = {"./idl", "-gen-cpp", "-c", CACHE_TIME_001_IDL_NAME.c_str()}; 65 int argc = 4; 66 ParameterArgv parameters(argvArray, argc); 67 68 Options options(parameters.argc_, parameters.argv_); 69 70 Parser p(options); 71 auto ret = p.Parse(options.GetSourceFile()); 72 EXPECT_EQ(ret, true); 73} 74 75/* 76 * @tc.name: CacheTimeTest002 77 * @tc.desc: test CacheTime 78 * @tc.type: FUNC 79 * @tc.require: 80 */ 81HWTEST_F(CacheableTest, CacheTimeTest002, Function | MediumTest | Level1) 82{ 83 GTEST_LOG_(INFO) << "CacheableTest, CacheTimeTest002, TestSize.Level1"; 84 85 PrepareIdlFile(CACHE_TIME_002_IDL_NAME.c_str(), 86 CACHEABLE_TIME_TEST002_IDL_CONTENT.c_str()); 87 88 const char* argvArray[] = {"./idl", "-gen-cpp", "-c", CACHE_TIME_002_IDL_NAME.c_str()}; 89 int argc = 4; 90 ParameterArgv parameters(argvArray, argc); 91 92 Options options(parameters.argc_, parameters.argv_); 93 94 Parser p(options); 95 auto ret = p.Parse(options.GetSourceFile()); 96 EXPECT_EQ(ret, false); 97} 98 99/* 100 * @tc.name: CacheTimeTest003 101 * @tc.desc: test CacheTime 102 * @tc.type: FUNC 103 * @tc.require: 104 */ 105HWTEST_F(CacheableTest, CacheTimeTest003, Function | MediumTest | Level1) 106{ 107 GTEST_LOG_(INFO) << "CacheableTest, CacheTimeTest003, TestSize.Level1"; 108 109 PrepareIdlFile(CACHE_TIME_003_IDL_NAME.c_str(), 110 CACHEABLE_TIME_TEST003_IDL_CONTENT.c_str()); 111 112 const char* argvArray[] = {"./idl", "-gen-cpp", "-c", CACHE_TIME_003_IDL_NAME.c_str()}; 113 int argc = 4; 114 ParameterArgv parameters(argvArray, argc); 115 116 Options options(parameters.argc_, parameters.argv_); 117 118 Parser p(options); 119 auto ret = p.Parse(options.GetSourceFile()); 120 EXPECT_EQ(ret, false); 121} 122 123/* 124 * @tc.name: CacheTimeTest004 125 * @tc.desc: test CacheTime 126 * @tc.type: FUNC 127 * @tc.require: 128 */ 129HWTEST_F(CacheableTest, CacheTimeTest004, Function | MediumTest | Level1) 130{ 131 GTEST_LOG_(INFO) << "CacheableTest, CacheTimeTest004, TestSize.Level1"; 132 133 PrepareIdlFile(CACHE_TIME_004_IDL_NAME.c_str(), 134 CACHEABLE_TIME_TEST004_IDL_CONTENT.c_str()); 135 136 const char* argvArray[] = {"./idl", "-gen-cpp", "-c", CACHE_TIME_004_IDL_NAME.c_str()}; 137 int argc = 4; 138 ParameterArgv parameters(argvArray, argc); 139 140 Options options(parameters.argc_, parameters.argv_); 141 142 Parser p(options); 143 auto ret = p.Parse(options.GetSourceFile()); 144 EXPECT_EQ(ret, true); 145} 146 147/* 148 * @tc.name: CacheTimeTest005 149 * @tc.desc: test CacheTime 150 * @tc.type: FUNC 151 * @tc.require: 152 */ 153HWTEST_F(CacheableTest, CacheTimeTest005, Function | MediumTest | Level1) 154{ 155 GTEST_LOG_(INFO) << "CacheableTest, CacheTimeTest005, TestSize.Level1"; 156 157 PrepareIdlFile(CACHE_TIME_005_IDL_NAME.c_str(), 158 CACHEABLE_TIME_TEST005_IDL_CONTENT.c_str()); 159 160 const char* argvArray[] = {"./idl", "-gen-cpp", "-c", CACHE_TIME_005_IDL_NAME.c_str()}; 161 int argc = 4; 162 ParameterArgv parameters(argvArray, argc); 163 164 Options options(parameters.argc_, parameters.argv_); 165 166 Parser p(options); 167 auto ret = p.Parse(options.GetSourceFile()); 168 EXPECT_EQ(ret, false); 169} 170 171/* 172 * @tc.name: CacheTimeTest006 173 * @tc.desc: test CacheTime 174 * @tc.type: FUNC 175 * @tc.require: 176 */ 177HWTEST_F(CacheableTest, CacheTimeTest006, Function | MediumTest | Level1) 178{ 179 GTEST_LOG_(INFO) << "CacheableTest, CacheTimeTest006, TestSize.Level1"; 180 181 PrepareIdlFile(CACHE_TIME_006_IDL_NAME.c_str(), 182 CACHEABLE_TIME_TEST006_IDL_CONTENT.c_str()); 183 184 const char* argvArray[] = {"./idl", "-gen-cpp", "-c", CACHE_TIME_006_IDL_NAME.c_str()}; 185 int argc = 4; 186 ParameterArgv parameters(argvArray, argc); 187 188 Options options(parameters.argc_, parameters.argv_); 189 190 Parser p(options); 191 auto ret = p.Parse(options.GetSourceFile()); 192 EXPECT_EQ(ret, false); 193} 194 195/* 196 * @tc.name: CacheTimeTest007 197 * @tc.desc: test CacheTime 198 * @tc.type: FUNC 199 * @tc.require: 200 */ 201HWTEST_F(CacheableTest, CacheTimeTest007, Function | MediumTest | Level1) 202{ 203 GTEST_LOG_(INFO) << "CacheableTest, CacheTimeTest007, TestSize.Level1"; 204 205 PrepareIdlFile(CACHE_TIME_007_IDL_NAME.c_str(), 206 CACHEABLE_TIME_TEST007_IDL_CONTENT.c_str()); 207 208 const char* argvArray[] = {"./idl", "-gen-cpp", "-c", CACHE_TIME_007_IDL_NAME.c_str()}; 209 int argc = 4; 210 ParameterArgv parameters(argvArray, argc); 211 212 Options options(parameters.argc_, parameters.argv_); 213 214 Parser p(options); 215 auto ret = p.Parse(options.GetSourceFile()); 216 EXPECT_EQ(ret, true); 217} 218 219/* 220 * @tc.name: CacheTimeTest008 221 * @tc.desc: test CacheTime 222 * @tc.type: FUNC 223 * @tc.require: 224 */ 225HWTEST_F(CacheableTest, CacheTimeTest008, Function | MediumTest | Level1) 226{ 227 GTEST_LOG_(INFO) << "CacheableTest, CacheTimeTest008, TestSize.Level1"; 228 229 PrepareIdlFile(CACHE_TIME_008_IDL_NAME.c_str(), 230 CACHEABLE_TIME_TEST008_IDL_CONTENT.c_str()); 231 232 const char* argvArray[] = {"./idl", "-gen-cpp", "-c", CACHE_TIME_008_IDL_NAME.c_str()}; 233 int argc = 4; 234 ParameterArgv parameters(argvArray, argc); 235 236 Options options(parameters.argc_, parameters.argv_); 237 238 Parser p(options); 239 auto ret = p.Parse(options.GetSourceFile()); 240 EXPECT_EQ(ret, false); 241} 242 243/* 244 * @tc.name: CacheTimeTest009 245 * @tc.desc: test CacheTime 246 * @tc.type: FUNC 247 * @tc.require: 248 */ 249HWTEST_F(CacheableTest, CacheTimeTest009, Function | MediumTest | Level1) 250{ 251 GTEST_LOG_(INFO) << "CacheableTest, CacheTimeTest009, TestSize.Level1"; 252 253 PrepareIdlFile(CACHE_TIME_009_IDL_NAME.c_str(), 254 CACHEABLE_TIME_TEST009_IDL_CONTENT.c_str()); 255 256 const char* argvArray[] = {"./idl", "-gen-cpp", "-c", CACHE_TIME_009_IDL_NAME.c_str()}; 257 int argc = 4; 258 ParameterArgv parameters(argvArray, argc); 259 260 Options options(parameters.argc_, parameters.argv_); 261 262 Parser p(options); 263 auto ret = p.Parse(options.GetSourceFile()); 264 EXPECT_EQ(ret, false); 265} 266 267/* 268 * @tc.name: CacheTimeTest010 269 * @tc.desc: test CacheTime 270 * @tc.type: FUNC 271 * @tc.require: 272 */ 273HWTEST_F(CacheableTest, CacheTimeTest010, Function | MediumTest | Level1) 274{ 275 GTEST_LOG_(INFO) << "CacheableTest, CacheTimeTest010, TestSize.Level1"; 276 277 PrepareIdlFile(CACHE_TIME_010_IDL_NAME.c_str(), 278 CACHEABLE_TIME_TEST010_IDL_CONTENT.c_str()); 279 280 const char* argvArray[] = {"./idl", "-gen-cpp", "-c", CACHE_TIME_010_IDL_NAME.c_str()}; 281 int argc = 4; 282 ParameterArgv parameters(argvArray, argc); 283 284 Options options(parameters.argc_, parameters.argv_); 285 286 Parser p(options); 287 auto ret = p.Parse(options.GetSourceFile()); 288 EXPECT_EQ(ret, false); 289} 290} // namespace idl 291} // namespace OHOS