测试用例分析tests
一、文件个数
测试用例共包含 5 对类文件 及 2 个单文件,共12个文本文件
二、类的个数
controller. h
TestController
controller.cpp
RootTests
BaseTest.h
TestCase
TestBase
TestSuite
TestList
BaseTest
BaseTest.cpp
TestCustomTableView
testBasic.h
TestScene
VisibleRect.h
VisibleRect
testResource.h
tests.h
从上面列表中可以看出,共10个类
三、类的调用关系
1、 bool AppDelegate::applicationDidFinishLaunching() 函数中,取TestController的实例
_testController = TestController::getInstance();
2、new 一个 TestController 对象 - getInstance()
s_testController = new (std::nothrow) TestController;
3、new 对象是需要调用构造函数 - TestController()
TestController::TestController()
4、在 TestController 构造函数中 new RootTests 对象 - TestController()
_rootTestList = new (std::nothrow) RootTests;
5、new 对象是需要调用构造函数 - RootTests
RootTests()
6、RootTests继承自TestList,同时也需要初始化TestList构造函数
TestList::TestList() - 这个构造函数里只初始化了些参数
7、TestList继承自TestBase,同时也需要初始化TestBase构造函数
TestBase::TestBase()
8、TestBase继承自Ref,同时也需要初始化Ref构造函数
Ref::Ref()
9、开始初始化TestBase构造函数
10、开始初始化TestList构造函数
11、开始初始化RootTests构造函数,把需要被调用到的东西加入到vector中
addTest("Node: Scene3D", [](){return new (std::nothrow) Scene3DTests(); });
12、调用继承自TestList的 addTest函数,加载需要的东西
addTest("Node: Scene3D", [](){return new (std::nothrow) Scene3DTests(); });
13、回到 TestController 构造函数,执行下一句
_rootTestList->runThisTest();
14、取得导演
auto director = Director::getInstance();
15、创建 Scene 对象
auto scene = Scene::create();
16、通过导演对象取得可见区域(窗口大小)
auto visibleSize = director->getVisibleSize();
17、通过导演对象取得可见区域的起点坐标
auto origin = director->getVisibleOrigin();
未完待续……