mirror of https://github.com/oxen-io/session-ios
				
				
				
			
			You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
	
	
		
			68 lines
		
	
	
		
			2.5 KiB
		
	
	
	
		
			Matlab
		
	
		
		
			
		
	
	
			68 lines
		
	
	
		
			2.5 KiB
		
	
	
	
		
			Matlab
		
	
| 
								 
											9 years ago
										 
									 | 
							
								//
							 | 
						||
| 
								 | 
							
								//  Copyright (c) 2017 Open Whisper Systems. All rights reserved.
							 | 
						||
| 
								 | 
							
								//
							 | 
						||
| 
								 
											9 years ago
										 
									 | 
							
								
							 | 
						||
| 
								 | 
							
								#import "TSContactThread.h"
							 | 
						||
| 
								 | 
							
								#import "TSOutgoingMessage.h"
							 | 
						||
| 
								 | 
							
								#import <XCTest/XCTest.h>
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								NS_ASSUME_NONNULL_BEGIN
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								@interface TSOutgoingMessageTest : XCTestCase
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								@property (nonatomic) TSContactThread *thread;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								@end
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								@implementation TSOutgoingMessageTest
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								- (void)setUp
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    [super setUp];
							 | 
						||
| 
								 | 
							
								    self.thread = [[TSContactThread alloc] initWithUniqueId:@"fake-thread-id"];
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								- (void)testShouldNotStartExpireTimerWithMessageThatDoesNotExpire
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    TSOutgoingMessage *message = [[TSOutgoingMessage alloc] initWithTimestamp:100 inThread:self.thread messageBody:nil];
							 | 
						||
| 
								 | 
							
								    XCTAssertFalse(message.shouldStartExpireTimer);
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								- (void)testShouldStartExpireTimerWithSentMessage
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    TSOutgoingMessage *message = [[TSOutgoingMessage alloc] initWithTimestamp:100
							 | 
						||
| 
								 | 
							
								                                                                     inThread:self.thread
							 | 
						||
| 
								 | 
							
								                                                                  messageBody:nil
							 | 
						||
| 
								 | 
							
								                                                                attachmentIds:[NSMutableArray new]
							 | 
						||
| 
								 | 
							
								                                                             expiresInSeconds:10];
							 | 
						||
| 
								 
											9 years ago
										 
									 | 
							
								    [message updateWithMessageState:TSOutgoingMessageStateSentToService];
							 | 
						||
| 
								 
											9 years ago
										 
									 | 
							
								    XCTAssert(message.shouldStartExpireTimer);
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								- (void)testShouldNotStartExpireTimerWithUnsentMessage
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    TSOutgoingMessage *message = [[TSOutgoingMessage alloc] initWithTimestamp:100
							 | 
						||
| 
								 | 
							
								                                                                     inThread:self.thread
							 | 
						||
| 
								 | 
							
								                                                                  messageBody:nil
							 | 
						||
| 
								 | 
							
								                                                                attachmentIds:[NSMutableArray new]
							 | 
						||
| 
								 | 
							
								                                                             expiresInSeconds:10];
							 | 
						||
| 
								 
											9 years ago
										 
									 | 
							
								    [message updateWithMessageState:TSOutgoingMessageStateUnsent];
							 | 
						||
| 
								 
											9 years ago
										 
									 | 
							
								    XCTAssertFalse(message.shouldStartExpireTimer);
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								- (void)testShouldNotStartExpireTimerWithAttemptingOutMessage
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    TSOutgoingMessage *message = [[TSOutgoingMessage alloc] initWithTimestamp:100
							 | 
						||
| 
								 | 
							
								                                                                     inThread:self.thread
							 | 
						||
| 
								 | 
							
								                                                                  messageBody:nil
							 | 
						||
| 
								 | 
							
								                                                                attachmentIds:[NSMutableArray new]
							 | 
						||
| 
								 | 
							
								                                                             expiresInSeconds:10];
							 | 
						||
| 
								 
											9 years ago
										 
									 | 
							
								    [message updateWithMessageState:TSOutgoingMessageStateAttemptingOut];
							 | 
						||
| 
								 
											9 years ago
										 
									 | 
							
								    XCTAssertFalse(message.shouldStartExpireTimer);
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								@end
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								NS_ASSUME_NONNULL_END
							 |