• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*-------------------------------------------------------------------------
2 * drawElements Quality Program Tester Core
3 * ----------------------------------------
4 *
5 * Copyright 2014 The Android Open Source Project
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 *      http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 *
19 *//*!
20 * \file
21 * \brief iOS View Controller.
22 *//*--------------------------------------------------------------------*/
23
24#import <QuartzCore/QuartzCore.h>
25
26#import "tcuIOSViewController.h"
27#import "tcuEAGLView.h"
28
29#include "qpDebugOut.h"
30
31@interface tcuIOSViewController ()
32@property (nonatomic, assign) CADisplayLink *displayLink;
33@end
34
35@implementation tcuIOSViewController
36
37@synthesize displayLink;
38
39- (void)loadView
40{
41	tcuEAGLView *view = [[tcuEAGLView alloc] initWithFrame:[UIScreen mainScreen].applicationFrame];
42	self.view = view;
43	[view release];
44}
45
46- (void)viewDidLoad
47{
48	[super viewDidLoad];
49
50    isIterating			= FALSE;
51    self.displayLink	= nil;
52	app					= tcuIOSApp_create(self.view);
53}
54
55- (void)dealloc
56{
57	[super dealloc];
58}
59
60- (void)didReceiveMemoryWarning
61{
62	[super didReceiveMemoryWarning];
63}
64
65- (void)viewWillAppear:(BOOL)animated
66{
67	[super viewWillAppear:animated];
68}
69
70- (void)viewWillDisappear:(BOOL)animated
71{
72	[super viewWillDisappear:animated];
73}
74
75- (void)viewDidUnload
76{
77	[super viewDidUnload];
78}
79
80- (void)startTestIteration
81{
82    if (!isIterating)
83	{
84		DE_ASSERT(self.displayLink == nil);
85
86		// Obtain display link.
87        self.displayLink = [[UIScreen mainScreen] displayLinkWithTarget:self selector:@selector(iterate)];
88        [self.displayLink setFrameInterval:1];
89        [self.displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
90
91        isIterating = TRUE;
92    }
93}
94
95- (void)stopTestIteration
96{
97    if (isIterating)
98	{
99        isIterating = FALSE;
100        [self.displayLink invalidate];
101        self.displayLink = nil;
102    }
103}
104
105- (void)iterate
106{
107	if (isIterating)
108	{
109		deBool result = tcuIOSApp_iterate(app);
110
111		if (!result)
112		{
113			[self stopTestIteration];
114			qpDief("Fatal error occurred in test execution, killing process.");
115		}
116	}
117}
118
119@end
120