forked from ParisiLabs/wire-ios
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathParticipantDeviceCellTests.m
89 lines (73 loc) · 3.07 KB
/
ParticipantDeviceCellTests.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
//
// Wire
// Copyright (C) 2016 Wire Swiss GmbH
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see http://www.gnu.org/licenses/.
//
#import <zmessaging/zmessaging.h>
#import "ZMSnapshotTestCase.h"
#import <PureLayout/PureLayout.h>
#import "ParticipantDeviceCell.h"
#import "Wire_iOS_Tests-Swift.h"
@interface ParticipantDeviceCellTests : ZMSnapshotTestCase
@property (nonatomic) ParticipantDeviceCell *sut;
@property (nonatomic) ZMUser *user;
@end
@implementation ParticipantDeviceCellTests
- (void)setUp
{
[super setUp];
self.sut = [[ParticipantDeviceCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"reuseIdentifier"];
[self.sut autoSetDimension:ALDimensionHeight toSize:64]; // This is a fixed height cell
self.user = [ZMUser insertNewObjectInManagedObjectContext:self.uiMOC];
}
- (void)testThatItRendersTheCellUnverifiedFullWidthIdentifierLongerThan_16_Characters
{
UserClient *client = [UserClient fetchUserClientWithRemoteId:@"102030405060708090" forUser:self.user createIfNeeded:YES];
client.deviceClass = @"tablet";
[self.sut configureForClient:client];
ZMVerifyView([self.sut wrapInTableView]);
}
- (void)testThatItRendersTheCellUnverifiedTruncatedIdentifier
{
UserClient *client = [UserClient fetchUserClientWithRemoteId:@"807060504030201" forUser:self.user createIfNeeded:YES];
client.deviceClass = @"desktop";
[self.sut configureForClient:client];
ZMVerifyView([self.sut wrapInTableView]);
}
- (void)testThatItRendersTheCellUnverifiedTruncatedIdentifierMultipleCharactersMissing
{
UserClient *client = [UserClient fetchUserClientWithRemoteId:@"7060504030201" forUser:self.user createIfNeeded:YES];
client.deviceClass = @"desktop";
[self.sut configureForClient:client];
ZMVerifyView([self.sut wrapInTableView]);
}
- (void)testThatItRendersTheCellVerifiedWithLabel
{
UserClient *client = [UserClient fetchUserClientWithRemoteId:@"e7b2u9d4s85h1gv0" forUser:self.user createIfNeeded:YES];
client.deviceClass = @"phone";
[self trustClient:client];
[self.sut configureForClient:client];
ZMVerifyView([self.sut wrapInTableView]);
}
#pragma mark - Helper
- (void)trustClient:(UserClient *)client
{
UserClient *selfClient = [UserClient insertNewObjectInManagedObjectContext:self.uiMOC];
selfClient.remoteIdentifier = @"selfClientID";
[self.uiMOC setPersistentStoreMetadata:@"selfClientID" forKey:ZMPersistedClientIdKey];
selfClient.user = [ZMUser selfUserInContext:self.uiMOC];
[selfClient trustClient:client];
}
@end