Skip to content
Browse files

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...
1 parent a77bc5c commit 35175446cf40ea2656dfc62abc279247e7588965 Zac White committed Oct 13, 2009
Showing with 16 additions and 20 deletions.
  1. +1 −3 ARKitDemo/Classes/ARGeoCoordinate.m
  2. +8 −9 ARKitDemo/Classes/ARViewController.m
  3. +1 −1 ARKitDemo/LogicTests.h
  4. +6 −7 ARKitDemo/LogicTests.m
View
4 ARKitDemo/Classes/ARGeoCoordinate.m
@@ -31,9 +31,7 @@ - (void)calibrateUsingOrigin:(CLLocation *)origin {
double baseDistance = [origin getDistanceFrom:self.geoLocation];
self.radialDistance = sqrt(pow(origin.altitude - self.geoLocation.altitude, 2) + pow(baseDistance, 2));
-
- NSLog(@"%@ origin.altitude: %f self.geoLocation.altitude: %f", self.title, origin.altitude, self.geoLocation.altitude);
-
+
float angle = sin(ABS(origin.altitude - self.geoLocation.altitude) / self.radialDistance);
if (origin.altitude > self.geoLocation.altitude) angle = -angle;
View
17 ARKitDemo/Classes/ARViewController.m
@@ -89,12 +89,15 @@ - (void)loadView {
ar_overlayView = [[UIView alloc] initWithFrame:CGRectZero];
[ar_debugView release];
- ar_debugView = [[UILabel alloc] initWithFrame:CGRectZero];
- ar_debugView.textAlignment = UITextAlignmentCenter;
- ar_debugView.text = @"Waiting...";
-
- if (self.debugMode) [ar_overlayView addSubview:ar_debugView];
+ if (self.debugMode) {
+ ar_debugView = [[UILabel alloc] initWithFrame:CGRectZero];
+ ar_debugView.textAlignment = UITextAlignmentCenter;
+ ar_debugView.text = @"Waiting...";
+
+ [ar_overlayView addSubview:ar_debugView];
+ }
+
self.view = ar_overlayView;
}
@@ -126,10 +129,6 @@ - (void)setDebugMode:(BOOL)flag {
else [ar_debugView removeFromSuperview];
}
-- (void)viewDidLoad {
- [super viewDidLoad];
-}
-
- (BOOL)viewportContainsCoordinate:(ARCoordinate *)coordinate {
double centerAzimuth = self.centerCoordinate.azimuth;
double leftAzimuth = centerAzimuth - VIEWPORT_WIDTH_RADIANS / 2.0;
View
2 ARKitDemo/LogicTests.h
@@ -27,5 +27,5 @@
@end
@interface LogicTests (ARViewControllerTests)
-- (void)testPointInView;
+- (void)testViewportContainsCenter;
@end
View
13 ARKitDemo/LogicTests.m
@@ -32,23 +32,22 @@ @implementation LogicTests (ARCoordinateTests)
@implementation LogicTests (ARViewControllerTests)
-- (void)testPointInView {
-
+- (void)testViewportContainsCenter {
+
ARViewController *viewController = [[ARViewController alloc] init];
+ viewController.debugMode = NO;
ARCoordinate *coordinate = [[ARCoordinate alloc] init];
coordinate.azimuth = 0.0;
coordinate.inclination = 0.0;
coordinate.radialDistance = 10.0;
- CGPoint thePoint = [viewController pointInView:viewController.view forCoordinate:coordinate];
-
- CGRect viewRect = viewController.view.frame;
+ viewController.centerCoordinate = coordinate;
+
+ STAssertTrue([viewController viewportContainsCoordinate:coordinate], @"Viewport does not contain center.");
[coordinate release];
[viewController release];
-
- STAssertTrue(CGRectContainsPoint(viewRect, thePoint), @"Rect doesn't contain point.");
}
@end

0 comments on commit 3517544

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