summaryrefslogtreecommitdiff
path: root/objective-c/test
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2015-09-14 15:43:34 +0200
committerBenoit Foucher <benoit@zeroc.com>2015-09-14 15:43:34 +0200
commit13bed6dec104b53fadf723aead0dc15dc3f2afd8 (patch)
treed6401dbe7d70d65e04e448439e4056c1fa4d7e8c /objective-c/test
parentRemoved ARM configuraton from WinRT testsuite solutions (diff)
downloadice-13bed6dec104b53fadf723aead0dc15dc3f2afd8.tar.bz2
ice-13bed6dec104b53fadf723aead0dc15dc3f2afd8.tar.xz
ice-13bed6dec104b53fadf723aead0dc15dc3f2afd8.zip
Fixed ICE-6812 - JavaScript ACM monitor bug
Diffstat (limited to 'objective-c/test')
-rw-r--r--objective-c/test/Ice/acm/ACMTest.ice1
-rw-r--r--objective-c/test/Ice/acm/AllTests.m16
-rw-r--r--objective-c/test/Ice/acm/TestI.m56
3 files changed, 66 insertions, 7 deletions
diff --git a/objective-c/test/Ice/acm/ACMTest.ice b/objective-c/test/Ice/acm/ACMTest.ice
index 1e6bcd7eb69..7b492d9b356 100644
--- a/objective-c/test/Ice/acm/ACMTest.ice
+++ b/objective-c/test/Ice/acm/ACMTest.ice
@@ -18,6 +18,7 @@ interface TestIntf
void sleep(int seconds);
void sleepAndHold(int seconds);
void interruptSleep();
+ void waitForHeartbeat(int count);
};
interface RemoteObjectAdapter
diff --git a/objective-c/test/Ice/acm/AllTests.m b/objective-c/test/Ice/acm/AllTests.m
index ca9d73278db..4499108ab4b 100644
--- a/objective-c/test/Ice/acm/AllTests.m
+++ b/objective-c/test/Ice/acm/AllTests.m
@@ -760,7 +760,7 @@
+(id) testCase:(id<TestACMRemoteCommunicatorPrx>)com
{
id tc = [super testCase:com];
- [tc setClientACM:15 close:4 heartbeat:2];
+ [tc setClientACM:15 close:4 heartbeat:0];
return tc;
}
+(NSString*) getName
@@ -772,22 +772,24 @@
ICEACM* acm = [[proxy ice_getCachedConnection] getACM];
test(acm.timeout == 15);
test(acm.close == ICECloseOnIdleForceful);
- test(acm.heartbeat == ICEHeartbeatOnIdle);
+ test(acm.heartbeat == ICEHeartbeatOff);
[[proxy ice_getCachedConnection] setACM:ICENone close:ICENone heartbeat:ICENone];
acm = [[proxy ice_getCachedConnection] getACM];
test(acm.timeout == 15);
test(acm.close == ICECloseOnIdleForceful);
- test(acm.heartbeat == ICEHeartbeatOnIdle);
+ test(acm.heartbeat == ICEHeartbeatOff);
- id timeout = @20;
+ id timeout = @1;
id close = @(ICECloseOnInvocationAndIdle);
- id heartbeat = @(ICEHeartbeatOnInvocation);
+ id heartbeat = @(ICEHeartbeatAlways);
[[proxy ice_getCachedConnection] setACM:timeout close:close heartbeat:heartbeat];
acm = [[proxy ice_getCachedConnection] getACM];
- test(acm.timeout == 20);
+ test(acm.timeout == 1);
test(acm.close == ICECloseOnInvocationAndIdle);
- test(acm.heartbeat == ICEHeartbeatOnInvocation);
+ test(acm.heartbeat == ICEHeartbeatAlways);
+
+ [proxy waitForHeartbeat:2];
}
@end
diff --git a/objective-c/test/Ice/acm/TestI.m b/objective-c/test/Ice/acm/TestI.m
index 5de0e0eeb88..b0263bcb766 100644
--- a/objective-c/test/Ice/acm/TestI.m
+++ b/objective-c/test/Ice/acm/TestI.m
@@ -9,6 +9,55 @@
#import <acm/TestI.h>
+@interface ConnectionCallbackI : NSObject<ICEConnectionCallback>
+{
+ NSCondition* _cond;
+ int _count;
+}
+-(void) waitForCount:(int)count;
+@end
+
+
+@implementation ConnectionCallbackI
+-(id) init
+{
+ self = [super init];
+ if(!self)
+ {
+ return nil;
+ }
+ _cond = [[NSCondition alloc] init];
+ _count = 0;
+ return self;
+}
+-(void) heartbeat:(id<ICEConnection>)c
+{
+ [_cond lock];
+ --_count;
+ [_cond signal];
+ [_cond unlock];
+}
+-(void) closed:(id<ICEConnection>)c
+{
+}
+-(void) waitForCount:(int)count
+{
+ [_cond lock];
+ _count = count;
+ @try
+ {
+ while(_count > 0)
+ {
+ [_cond wait];
+ }
+ }
+ @finally
+ {
+ [_cond unlock];
+ }
+}
+@end
+
@implementation RemoteCommunicatorI
-(id<TestACMRemoteObjectAdapterPrx>) createObjectAdapter:(ICEInt)timeout close:(ICEInt)close heartbeat:(ICEInt)heartbeat
current:(ICECurrent*)current
@@ -146,4 +195,11 @@
[_cond signal];
[_cond unlock];
}
+-(void) waitForHeartbeat:(int)count current:(ICECurrent*)current
+{
+ ConnectionCallbackI* callback = [ConnectionCallbackI new];
+ [current.con setCallback:callback];
+ [callback waitForCount:count];
+ [callback release];
+}
@end