Skip to content
This repository
Browse code

Turned off creating the debug view unless debug mode is on. Fixed the…

… logic tests so they compile. Added a custom executable so debugging the tests is possible. Added a new unit test and removed the old one.
  • Loading branch information...
commit 35175446cf40ea2656dfc62abc279247e7588965 1 parent a77bc5c
Zac White authored
4 ARKitDemo/Classes/ARGeoCoordinate.m
@@ -31,9 +31,7 @@ - (void)calibrateUsingOrigin:(CLLocation *)origin {
31 31 double baseDistance = [origin getDistanceFrom:self.geoLocation];
32 32
33 33 self.radialDistance = sqrt(pow(origin.altitude - self.geoLocation.altitude, 2) + pow(baseDistance, 2));
34   -
35   - NSLog(@"%@ origin.altitude: %f self.geoLocation.altitude: %f", self.title, origin.altitude, self.geoLocation.altitude);
36   -
  34 +
37 35 float angle = sin(ABS(origin.altitude - self.geoLocation.altitude) / self.radialDistance);
38 36
39 37 if (origin.altitude > self.geoLocation.altitude) angle = -angle;
17 ARKitDemo/Classes/ARViewController.m
@@ -89,12 +89,15 @@ - (void)loadView {
89 89 ar_overlayView = [[UIView alloc] initWithFrame:CGRectZero];
90 90
91 91 [ar_debugView release];
92   - ar_debugView = [[UILabel alloc] initWithFrame:CGRectZero];
93   - ar_debugView.textAlignment = UITextAlignmentCenter;
94   - ar_debugView.text = @"Waiting...";
95   -
96   - if (self.debugMode) [ar_overlayView addSubview:ar_debugView];
97 92
  93 + if (self.debugMode) {
  94 + ar_debugView = [[UILabel alloc] initWithFrame:CGRectZero];
  95 + ar_debugView.textAlignment = UITextAlignmentCenter;
  96 + ar_debugView.text = @"Waiting...";
  97 +
  98 + [ar_overlayView addSubview:ar_debugView];
  99 + }
  100 +
98 101 self.view = ar_overlayView;
99 102 }
100 103
@@ -126,10 +129,6 @@ - (void)setDebugMode:(BOOL)flag {
126 129 else [ar_debugView removeFromSuperview];
127 130 }
128 131
129   -- (void)viewDidLoad {
130   - [super viewDidLoad];
131   -}
132   -
133 132 - (BOOL)viewportContainsCoordinate:(ARCoordinate *)coordinate {
134 133 double centerAzimuth = self.centerCoordinate.azimuth;
135 134 double leftAzimuth = centerAzimuth - VIEWPORT_WIDTH_RADIANS / 2.0;
2  ARKitDemo/LogicTests.h
@@ -27,5 +27,5 @@
27 27 @end
28 28
29 29 @interface LogicTests (ARViewControllerTests)
30   -- (void)testPointInView;
  30 +- (void)testViewportContainsCenter;
31 31 @end
13 ARKitDemo/LogicTests.m
@@ -32,23 +32,22 @@ @implementation LogicTests (ARCoordinateTests)
32 32
33 33 @implementation LogicTests (ARViewControllerTests)
34 34
35   -- (void)testPointInView {
36   -
  35 +- (void)testViewportContainsCenter {
  36 +
37 37 ARViewController *viewController = [[ARViewController alloc] init];
  38 + viewController.debugMode = NO;
38 39
39 40 ARCoordinate *coordinate = [[ARCoordinate alloc] init];
40 41 coordinate.azimuth = 0.0;
41 42 coordinate.inclination = 0.0;
42 43 coordinate.radialDistance = 10.0;
43 44
44   - CGPoint thePoint = [viewController pointInView:viewController.view forCoordinate:coordinate];
45   -
46   - CGRect viewRect = viewController.view.frame;
  45 + viewController.centerCoordinate = coordinate;
  46 +
  47 + STAssertTrue([viewController viewportContainsCoordinate:coordinate], @"Viewport does not contain center.");
47 48
48 49 [coordinate release];
49 50 [viewController release];
50   -
51   - STAssertTrue(CGRectContainsPoint(viewRect, thePoint), @"Rect doesn't contain point.");
52 51 }
53 52
54 53 @end

0 comments on commit 3517544

Please sign in to comment.
Something went wrong with that request. Please try again.