Changeset 11013
- Timestamp:
- Jan 2, 2016, 11:48:40 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/test/core_plugin/PluginTest.cc
r11012 r11013 21 21 { 22 22 public: 23 PluginTest() 24 { 25 this->plugin_ = NULL; 26 } 27 23 28 static void SetUpTestCase() 24 29 { … … 30 35 delete &Core::getInstance(); 31 36 } 37 38 void loadPlugin() 39 { 40 this->plugin_ = new PluginReference("testplugin"); 41 } 42 43 void unloadPlugin() 44 { 45 delete this->plugin_; 46 this->plugin_ = NULL; 47 } 48 49 virtual void TearDown() 50 { 51 // make sure the plugin is unloaded 52 this->unloadPlugin(); 53 } 54 55 private: 56 PluginReference* plugin_; 32 57 }; 33 58 } 34 59 35 PluginReference* loadPlugin()36 {37 return new PluginReference("testplugin");38 }39 60 40 61 TEST_F(PluginTest, CanLoadPlugin) 41 62 { 42 PluginReference* plugin =loadPlugin();43 delete plugin;63 this->loadPlugin(); 64 this->unloadPlugin(); 44 65 } 45 66 … … 57 78 { 58 79 EXPECT_TRUE(getIdentifier() == NULL); 59 PluginReference* plugin =loadPlugin();60 EXPECT_TRUE(getIdentifier() != NULL); 61 delete plugin;80 this->loadPlugin(); 81 EXPECT_TRUE(getIdentifier() != NULL); 82 this->unloadPlugin(); 62 83 } 63 84 64 85 TEST_F(PluginTest, UnloadsIdentifier) 65 86 { 66 PluginReference* plugin =loadPlugin();67 EXPECT_TRUE(getIdentifier() != NULL); 68 delete plugin;87 this->loadPlugin(); 88 EXPECT_TRUE(getIdentifier() != NULL); 89 this->unloadPlugin(); 69 90 EXPECT_TRUE(getIdentifier() == NULL); 70 91 } … … 72 93 TEST_F(PluginTest, ReloadsIdentifier) 73 94 { 74 PluginReference* plugin =loadPlugin();75 EXPECT_TRUE(getIdentifier() != NULL); 76 delete plugin;95 this->loadPlugin(); 96 EXPECT_TRUE(getIdentifier() != NULL); 97 this->unloadPlugin(); 77 98 EXPECT_TRUE(getIdentifier() == NULL); 78 plugin =loadPlugin();79 EXPECT_TRUE(getIdentifier() != NULL); 80 delete plugin;99 this->loadPlugin(); 100 EXPECT_TRUE(getIdentifier() != NULL); 101 this->unloadPlugin(); 81 102 } 82 103 83 104 TEST_F(PluginTest, CanCreateObjectFromIdentifier) 84 105 { 85 PluginReference* plugin =loadPlugin();106 this->loadPlugin(); 86 107 87 108 Identifier* identifier = getIdentifier(); … … 96 117 EXPECT_EQ(666, testclass->getValue()); 97 118 98 delete plugin;119 this->unloadPlugin(); 99 120 } 100 121 … … 131 152 { 132 153 EXPECT_TRUE(getSingleton() == NULL); 133 PluginReference* plugin =loadPlugin();134 EXPECT_TRUE(getSingleton() != NULL); 135 delete plugin;154 this->loadPlugin(); 155 EXPECT_TRUE(getSingleton() != NULL); 156 this->unloadPlugin(); 136 157 } 137 158 138 159 TEST_F(PluginTest, UnloadsSingleton) 139 160 { 140 PluginReference* plugin =loadPlugin();141 EXPECT_TRUE(getSingleton() != NULL); 142 delete plugin;161 this->loadPlugin(); 162 EXPECT_TRUE(getSingleton() != NULL); 163 this->unloadPlugin(); 143 164 EXPECT_TRUE(getSingleton() == NULL); 144 165 } … … 146 167 TEST_F(PluginTest, ReloadsSingleton) 147 168 { 148 PluginReference* plugin =loadPlugin();149 EXPECT_TRUE(getSingleton() != NULL); 150 delete plugin;169 this->loadPlugin(); 170 EXPECT_TRUE(getSingleton() != NULL); 171 this->unloadPlugin(); 151 172 EXPECT_TRUE(getSingleton() == NULL); 152 plugin =loadPlugin();153 EXPECT_TRUE(getSingleton() != NULL); 154 delete plugin;173 this->loadPlugin(); 174 EXPECT_TRUE(getSingleton() != NULL); 175 this->unloadPlugin(); 155 176 } 156 177 157 178 TEST_F(PluginTest, CanCallFunctionOnSingleton) 158 179 { 159 PluginReference* plugin =loadPlugin();180 this->loadPlugin(); 160 181 161 182 Testsingleton* singleton = getSingleton(); … … 164 185 EXPECT_EQ(999, singleton->getValue()); 165 186 166 delete plugin;187 this->unloadPlugin(); 167 188 } 168 189 … … 188 209 { 189 210 EXPECT_FALSE(hasCommandLineArgument()); 190 PluginReference* plugin =loadPlugin();191 EXPECT_TRUE(hasCommandLineArgument()); 192 delete plugin;211 this->loadPlugin(); 212 EXPECT_TRUE(hasCommandLineArgument()); 213 this->unloadPlugin(); 193 214 } 194 215 195 216 TEST_F(PluginTest, UnloadsCommandLineArgument) 196 217 { 197 PluginReference* plugin =loadPlugin();198 EXPECT_TRUE(hasCommandLineArgument()); 199 delete plugin;218 this->loadPlugin(); 219 EXPECT_TRUE(hasCommandLineArgument()); 220 this->unloadPlugin(); 200 221 EXPECT_FALSE(hasCommandLineArgument()); 201 222 } … … 203 224 TEST_F(PluginTest, ReloadsCommandLineArgument) 204 225 { 205 PluginReference* plugin =loadPlugin();206 EXPECT_TRUE(hasCommandLineArgument()); 207 delete plugin;226 this->loadPlugin(); 227 EXPECT_TRUE(hasCommandLineArgument()); 228 this->unloadPlugin(); 208 229 EXPECT_FALSE(hasCommandLineArgument()); 209 plugin =loadPlugin();210 EXPECT_TRUE(hasCommandLineArgument()); 211 delete plugin;230 this->loadPlugin(); 231 EXPECT_TRUE(hasCommandLineArgument()); 232 this->unloadPlugin(); 212 233 } 213 234 214 235 TEST_F(PluginTest, CommandLineArgumentHasCorrectValue) 215 236 { 216 PluginReference* plugin =loadPlugin();237 this->loadPlugin(); 217 238 218 239 ASSERT_TRUE(hasCommandLineArgument()); 219 240 EXPECT_EQ(333, CommandLineParser::getValue("testvalue").get<int>()); 220 241 221 delete plugin;242 this->unloadPlugin(); 222 243 } 223 244 … … 235 256 { 236 257 EXPECT_TRUE(getConsoleCommand() == NULL); 237 PluginReference* plugin =loadPlugin();238 EXPECT_TRUE(getConsoleCommand() != NULL); 239 delete plugin;258 this->loadPlugin(); 259 EXPECT_TRUE(getConsoleCommand() != NULL); 260 this->unloadPlugin(); 240 261 } 241 262 242 263 TEST_F(PluginTest, UnloadsConsoleCommand) 243 264 { 244 PluginReference* plugin =loadPlugin();245 EXPECT_TRUE(getConsoleCommand() != NULL); 246 delete plugin;265 this->loadPlugin(); 266 EXPECT_TRUE(getConsoleCommand() != NULL); 267 this->unloadPlugin(); 247 268 EXPECT_TRUE(getConsoleCommand() == NULL); 248 269 } … … 250 271 TEST_F(PluginTest, ReloadsConsoleCommand) 251 272 { 252 PluginReference* plugin =loadPlugin();253 EXPECT_TRUE(getConsoleCommand() != NULL); 254 delete plugin;273 this->loadPlugin(); 274 EXPECT_TRUE(getConsoleCommand() != NULL); 275 this->unloadPlugin(); 255 276 EXPECT_TRUE(getConsoleCommand() == NULL); 256 plugin =loadPlugin();257 EXPECT_TRUE(getConsoleCommand() != NULL); 258 delete plugin;277 this->loadPlugin(); 278 EXPECT_TRUE(getConsoleCommand() != NULL); 279 this->unloadPlugin(); 259 280 } 260 281 261 282 TEST_F(PluginTest, CanCallConsoleCommand) 262 283 { 263 PluginReference* plugin =loadPlugin();284 this->loadPlugin(); 264 285 265 286 ConsoleCommand* command = getConsoleCommand(); … … 268 289 EXPECT_EQ(999, (*command->getExecutor())(333, 666).get<int>()); 269 290 270 delete plugin;291 this->unloadPlugin(); 271 292 } 272 293 }
Note: See TracChangeset
for help on using the changeset viewer.