Permalink
Browse files

Move Touch category out of UIQuery and into it's own file TouchSynthesis

  • Loading branch information...
1 parent b737d47 commit 89d156e694453ae5e1db67d78eb5ea26822e3960 @steven-solomon committed Jun 11, 2011
View
@@ -0,0 +1,20 @@
+//
+// TouchSynthesis.h
+// SelfTesting
+//
+// Created by Matt Gallagher on 23/11/08.
+// Copyright 2008 Matt Gallagher. All rights reserved.
+//
+// Permission is given to use this source code file, free of charge, in any
+// project, commercial or otherwise, entirely at your risk, with the condition
+// that any redistribution (in part or whole) of source code must retain
+// this copyright and permission notice. Attribution in compiled projects is
+// appreciated but not required.
+//
+
+@interface UITouch (Synthesize)
+- (id)initInView:(UIView *)view;
+- (id)initInView:(UIView *)view xcoord:(int)x ycoord:(int)y;
+- (void)setPhase:(UITouchPhase)phase;
+- (void)setLocationInWindow:(CGPoint)location;
+@end
View
@@ -0,0 +1,117 @@
+//
+// TouchSynthesis.m
+// SelfTesting
+//
+// Created by Matt Gallagher on 23/11/08.
+// Copyright 2008 Matt Gallagher. All rights reserved.
+//
+// Permission is given to use this source code file, free of charge, in any
+// project, commercial or otherwise, entirely at your risk, with the condition
+// that any redistribution (in part or whole) of source code must retain
+// this copyright and permission notice. Attribution in compiled projects is
+// appreciated but not required.
+//
+
+@implementation UITouch (Synthesize)
+
+//
+// initInView:phase:
+//
+// Creats a UITouch, centered on the specified view, in the view's window.
+// Sets the phase as specified.
+//
+- (id)initInView:(UIView *)view
+{
+ self = [super init];
+ if (self != nil)
+ {
+ CGRect frameInWindow;
+ if ([view isKindOfClass:[UIWindow class]])
+ {
+ frameInWindow = view.frame;
+ }
+ else
+ {
+ frameInWindow =
+ [view.window convertRect:view.frame fromView:view.superview];
+ }
+
+ _tapCount = 1;
+ _locationInWindow =
+ CGPointMake(
+ frameInWindow.origin.x + 0.5 * frameInWindow.size.width,
+ frameInWindow.origin.y + 0.5 * frameInWindow.size.height);
+ _previousLocationInWindow = _locationInWindow;
+
+ UIView *target = [view.window hitTest:_locationInWindow withEvent:nil];
+
+ _window = [view.window retain];
+ _view = [target retain];
+ _phase = UITouchPhaseBegan;
+ _touchFlags._firstTouchForView = 1;
+ _touchFlags._isTap = 1;
+ _timestamp = [NSDate timeIntervalSinceReferenceDate];
+ }
+ return self;
+}
+
+
+- (id)initInView:(UIView *)view xcoord:(int)x ycoord:(int)y
+{
+ self = [super init];
+ if (self != nil)
+ {
+ CGRect frameInWindow;
+ if ([view isKindOfClass:[UIWindow class]])
+ {
+ frameInWindow = view.frame;
+ }
+ else
+ {
+ frameInWindow =
+ [view.window convertRect:view.frame fromView:view.superview];
+ }
+
+ _tapCount = 1;
+ _locationInWindow =
+ CGPointMake(
+ frameInWindow.origin.x + x,
+ frameInWindow.origin.y + y);
+ _previousLocationInWindow = _locationInWindow;
+
+ UIView *target = [view.window hitTest:_locationInWindow withEvent:nil];
+
+ _window = [view.window retain];
+ _view = [target retain];
+ _phase = UITouchPhaseBegan;
+ _touchFlags._firstTouchForView = 1;
+ _touchFlags._isTap = 1;
+ _timestamp = [NSDate timeIntervalSinceReferenceDate];
+ }
+ return self;
+}
+
+//
+// setPhase:
+//
+// Setter to allow access to the _phase member.
+//
+- (void)setPhase:(UITouchPhase)phase
+{
+ _phase = phase;
+ _timestamp = [NSDate timeIntervalSinceReferenceDate];
+}
+
+//
+// setPhase:
+//
+// Setter to allow access to the _locationInWindow member.
+//
+- (void)setLocationInWindow:(CGPoint)location
+{
+ _previousLocationInWindow = _locationInWindow;
+ _locationInWindow = location;
+ _timestamp = [NSDate timeIntervalSinceReferenceDate];
+}
+
+@end
View
@@ -103,10 +103,3 @@ UIQuery * $(NSMutableString *script, ...);
@interface UIEvent (Synthesis)
- (id)initWithTouch:(UITouch *)touch;
@end
-
-@interface UITouch (Synthesize)
-- (id)initInView:(UIView *)view;
-- (id)initInView:(UIView *)view xcoord:(int)x ycoord:(int)y;
-- (void)setPhase:(UITouchPhase)phase;
-- (void)setLocationInWindow:(CGPoint)location;
-@end
View
@@ -18,6 +18,7 @@
#import "UIBug.h"
#import "UIQueryExpectation.h"
#import "VisibleTouch.h"
+#import "TouchSynthesis.h"
@implementation UIQuery
@@ -554,123 +555,6 @@ -(void)dealloc {
return result;
}
-//
-// TouchSynthesis.m
-// SelfTesting
-//
-// Created by Matt Gallagher on 23/11/08.
-// Copyright 2008 Matt Gallagher. All rights reserved.
-//
-// Permission is given to use this source code file, free of charge, in any
-// project, commercial or otherwise, entirely at your risk, with the condition
-// that any redistribution (in part or whole) of source code must retain
-// this copyright and permission notice. Attribution in compiled projects is
-// appreciated but not required.
-//
-
-@implementation UITouch (Synthesize)
-
-//
-// initInView:phase:
-//
-// Creats a UITouch, centered on the specified view, in the view's window.
-// Sets the phase as specified.
-//
-- (id)initInView:(UIView *)view
-{
- self = [super init];
- if (self != nil)
- {
- CGRect frameInWindow;
- if ([view isKindOfClass:[UIWindow class]])
- {
- frameInWindow = view.frame;
- }
- else
- {
- frameInWindow =
- [view.window convertRect:view.frame fromView:view.superview];
- }
-
- _tapCount = 1;
- _locationInWindow =
- CGPointMake(
- frameInWindow.origin.x + 0.5 * frameInWindow.size.width,
- frameInWindow.origin.y + 0.5 * frameInWindow.size.height);
- _previousLocationInWindow = _locationInWindow;
-
- UIView *target = [view.window hitTest:_locationInWindow withEvent:nil];
-
- _window = [view.window retain];
- _view = [target retain];
- _phase = UITouchPhaseBegan;
- _touchFlags._firstTouchForView = 1;
- _touchFlags._isTap = 1;
- _timestamp = [NSDate timeIntervalSinceReferenceDate];
- }
- return self;
-}
-
-
-- (id)initInView:(UIView *)view xcoord:(int)x ycoord:(int)y
-{
- self = [super init];
- if (self != nil)
- {
- CGRect frameInWindow;
- if ([view isKindOfClass:[UIWindow class]])
- {
- frameInWindow = view.frame;
- }
- else
- {
- frameInWindow =
- [view.window convertRect:view.frame fromView:view.superview];
- }
-
- _tapCount = 1;
- _locationInWindow =
- CGPointMake(
- frameInWindow.origin.x + x,
- frameInWindow.origin.y + y);
- _previousLocationInWindow = _locationInWindow;
-
- UIView *target = [view.window hitTest:_locationInWindow withEvent:nil];
-
- _window = [view.window retain];
- _view = [target retain];
- _phase = UITouchPhaseBegan;
- _touchFlags._firstTouchForView = 1;
- _touchFlags._isTap = 1;
- _timestamp = [NSDate timeIntervalSinceReferenceDate];
- }
- return self;
-}
-
-//
-// setPhase:
-//
-// Setter to allow access to the _phase member.
-//
-- (void)setPhase:(UITouchPhase)phase
-{
- _phase = phase;
- _timestamp = [NSDate timeIntervalSinceReferenceDate];
-}
-
-//
-// setPhase:
-//
-// Setter to allow access to the _locationInWindow member.
-//
-- (void)setLocationInWindow:(CGPoint)location
-{
- _previousLocationInWindow = _locationInWindow;
- _locationInWindow = location;
- _timestamp = [NSDate timeIntervalSinceReferenceDate];
-}
-
-@end
//
// GSEvent is an undeclared object. We don't need to use it ourselves but some
@@ -16,6 +16,9 @@
2FDBB76210EECD0200193065 /* UIQueryWebView.h in Headers */ = {isa = PBXBuildFile; fileRef = 2FDBB75A10EECD0200193065 /* UIQueryWebView.h */; settings = {ATTRIBUTES = (Public, ); }; };
2FDBB76310EECD0200193065 /* UIQueryWebView.m in Sources */ = {isa = PBXBuildFile; fileRef = 2FDBB75B10EECD0200193065 /* UIQueryWebView.m */; };
40C7CC2A12E9E854003FF22C /* DescribeUIExpectation.h in Headers */ = {isa = PBXBuildFile; fileRef = C7D4F2EC10BDA57C00B00019 /* DescribeUIExpectation.h */; };
+ 6413822213A42B1E001311E9 /* TouchSynthesis.h in Headers */ = {isa = PBXBuildFile; fileRef = 6413822013A42B1E001311E9 /* TouchSynthesis.h */; };
+ 6413822313A42B1E001311E9 /* TouchSynthesis.m in Sources */ = {isa = PBXBuildFile; fileRef = 6413822113A42B1E001311E9 /* TouchSynthesis.m */; };
+ 6413822513A42B3B001311E9 /* TouchSynthesis.m in Sources */ = {isa = PBXBuildFile; fileRef = 6413822113A42B1E001311E9 /* TouchSynthesis.m */; };
64672D8913A2B8FC000C0271 /* VisibleTouch.h in Headers */ = {isa = PBXBuildFile; fileRef = 64672D8713A2B8FC000C0271 /* VisibleTouch.h */; };
64672D8A13A2B8FC000C0271 /* VisibleTouch.m in Sources */ = {isa = PBXBuildFile; fileRef = 64672D8813A2B8FC000C0271 /* VisibleTouch.m */; };
64672D8B13A2B935000C0271 /* libUISpec.a in Frameworks */ = {isa = PBXBuildFile; fileRef = C76EB5D20F74586B00EF8398 /* libUISpec.a */; };
@@ -121,6 +124,8 @@
2FDBB75910EECD0200193065 /* UIQueryTabBar.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UIQueryTabBar.m; sourceTree = "<group>"; };
2FDBB75A10EECD0200193065 /* UIQueryWebView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIQueryWebView.h; sourceTree = "<group>"; };
2FDBB75B10EECD0200193065 /* UIQueryWebView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UIQueryWebView.m; sourceTree = "<group>"; };
+ 6413822013A42B1E001311E9 /* TouchSynthesis.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TouchSynthesis.h; sourceTree = "<group>"; };
+ 6413822113A42B1E001311E9 /* TouchSynthesis.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TouchSynthesis.m; sourceTree = "<group>"; };
64672D8513A2B8BF000C0271 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/System/Library/Frameworks/CoreGraphics.framework; sourceTree = DEVELOPER_DIR; };
64672D8713A2B8FC000C0271 /* VisibleTouch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VisibleTouch.h; sourceTree = "<group>"; };
64672D8813A2B8FC000C0271 /* VisibleTouch.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VisibleTouch.m; sourceTree = "<group>"; };
@@ -356,6 +361,8 @@
C77A47CF10C9903B00C1BF8D /* UIQueryExpectation.m */,
64672DB713A2BFAB000C0271 /* InvisibleFinger.h */,
64672DB813A2BFAB000C0271 /* InvisibleFinger.m */,
+ 6413822013A42B1E001311E9 /* TouchSynthesis.h */,
+ 6413822113A42B1E001311E9 /* TouchSynthesis.m */,
);
name = dsl;
path = ../../src/dsl;
@@ -446,6 +453,7 @@
B3C25CE01381E93500BB634B /* UIQueryScrollView.h in Headers */,
64672D8913A2B8FC000C0271 /* VisibleTouch.h in Headers */,
64672DB913A2BFAB000C0271 /* InvisibleFinger.h in Headers */,
+ 6413822213A42B1E001311E9 /* TouchSynthesis.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -561,6 +569,7 @@
64672DB313A2BCA1000C0271 /* GHUnitIOSTestMain.m in Sources */,
64672DB613A2BD2B000C0271 /* InvisibleFingerTests.m in Sources */,
64672DBB13A2BFAB000C0271 /* InvisibleFinger.m in Sources */,
+ 6413822513A42B3B001311E9 /* TouchSynthesis.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -599,6 +608,7 @@
B3C25CDF1381E93500BB634B /* UIQueryScrollView.m in Sources */,
64672D8A13A2B8FC000C0271 /* VisibleTouch.m in Sources */,
64672DBA13A2BFAB000C0271 /* InvisibleFinger.m in Sources */,
+ 6413822313A42B1E001311E9 /* TouchSynthesis.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Oops, something went wrong.

0 comments on commit 89d156e

Please sign in to comment.