Chromium Code Reviews| Index: webrtc/examples/objc/AppRTCMobile/tests/ARDSettingsModel_xctest.mm |
| diff --git a/webrtc/examples/objc/AppRTCMobile/tests/ARDSettingsModelTests.mm b/webrtc/examples/objc/AppRTCMobile/tests/ARDSettingsModel_xctest.mm |
| similarity index 56% |
| rename from webrtc/examples/objc/AppRTCMobile/tests/ARDSettingsModelTests.mm |
| rename to webrtc/examples/objc/AppRTCMobile/tests/ARDSettingsModel_xctest.mm |
| index 45a10451d228847d5e758976806fa21390a05663..d821483f47b12f7cc41de18082395403afed04bf 100644 |
| --- a/webrtc/examples/objc/AppRTCMobile/tests/ARDSettingsModelTests.mm |
| +++ b/webrtc/examples/objc/AppRTCMobile/tests/ARDSettingsModel_xctest.mm |
| @@ -10,13 +10,15 @@ |
| #import <Foundation/Foundation.h> |
| #import <OCMock/OCMock.h> |
| +#import <XCTest/XCTest.h> |
| + |
| +#import "WebRTC/RTCMediaConstraints.h" |
| + |
| #import "ARDSettingsModel+Private.h" |
| #import "ARDSettingsStore.h" |
| -#import "WebRTC/RTCMediaConstraints.h" |
| -#include "webrtc/base/gunit.h" |
| -@interface ARDSettingsModelTests : NSObject { |
| +@interface ARDSettingsModelTests : XCTestCase { |
| ARDSettingsModel *_model; |
| } |
| @@ -29,14 +31,6 @@ |
| @implementation ARDSettingsModelTests |
| -- (instancetype)init { |
| - self = [super init]; |
| - if (self) { |
| - _model = [[ARDSettingsModel alloc] init]; |
| - } |
| - return self; |
| -} |
| - |
| - (id)setupMockStoreWithMediaConstraintString:(NSString *)constraintString { |
| id storeMock = [OCMockObject mockForClass:[ARDSettingsStore class]]; |
| [([[storeMock stub] andReturn:constraintString]) videoResolutionConstraints]; |
| @@ -47,113 +41,49 @@ |
| return storeMock; |
| } |
| +- (void)setUp { |
| + _model = [[ARDSettingsModel alloc] init]; |
| +} |
| + |
| - (void)testDefaultMediaFromStore { |
| - // given |
| id storeMock = [self setupMockStoreWithMediaConstraintString:nil]; |
| - |
| [[storeMock expect] setVideoResolutionConstraints:@"640x480"]; |
| - // when |
| NSString *string = [_model currentVideoResoultionConstraintFromStore]; |
| - // then |
| - EXPECT_TRUE([string isEqualToString:@"640x480"]); |
| + XCTAssertEqual(string, @"640x480"); |
|
daniela-webrtc
2017/02/13 16:08:22
Use XCTAssertEqualObjects here as well.
kthelgason
2017/02/14 09:48:46
I wonder how this worked and the test passed?
|
| [storeMock verify]; |
| } |
| - (void)testStoringInavlidConstraintReturnsNo { |
| - // given |
| - id storeMock = [self setupMockStoreWithMediaConstraintString:@"960x480"]; |
|
magjed_webrtc
2017/02/13 15:57:36
What happened to this line? It's not included in t
daniela-webrtc
2017/02/13 16:08:22
+1
kthelgason
2017/02/14 09:48:46
storeMock is not used in this test.
magjed_webrtc
2017/02/14 10:00:28
No, but doesn't the call to setupMockStoreWithMedi
|
| - |
| - // when |
| - BOOL result = [_model storeVideoResoultionConstraint:@"960x480"]; |
| - |
| - // then |
| - EXPECT_FALSE(result); |
| + XCTAssertFalse([_model storeVideoResoultionConstraint:@"960x480"]); |
| } |
| - (void)testWidthConstraintFromStore { |
| - // given |
| [self setupMockStoreWithMediaConstraintString:@"1270x480"]; |
| - |
| - // when |
| NSString *width = [_model currentVideoResolutionWidthFromStore]; |
| - // then |
| - EXPECT_TRUE([width isEqualToString:@"1270"]); |
| + XCTAssertEqualObjects(width, @"1270"); |
| } |
| - (void)testHeightConstraintFromStore { |
| - // given |
| [self setupMockStoreWithMediaConstraintString:@"960x540"]; |
| - // when |
| NSString *height = [_model currentVideoResolutionHeightFromStore]; |
| - // then |
| - EXPECT_TRUE([height isEqualToString:@"540"]); |
| + XCTAssertEqualObjects(height, @"540"); |
| } |
| - (void)testConstraintComponentIsNilWhenInvalidConstraintString { |
| - // given |
| [self setupMockStoreWithMediaConstraintString:@"invalid"]; |
| - |
| - // when |
| NSString *width = [_model currentVideoResolutionWidthFromStore]; |
| - // then |
| - EXPECT_TRUE(width == nil); |
| + XCTAssertNil(width); |
| } |
| - (void)testConstraintsDictionaryIsNilWhenInvalidConstraintString { |
| - // given |
| [self setupMockStoreWithMediaConstraintString:@"invalid"]; |
| - |
| - // when |
| NSDictionary *constraintsDictionary = [_model currentMediaConstraintFromStoreAsRTCDictionary]; |
| - // then |
| - EXPECT_TRUE(constraintsDictionary == nil); |
| + XCTAssertNil(constraintsDictionary); |
| } |
| @end |
| - |
| -class ARDSettingsModelTest : public ::testing::Test { |
| - protected: |
| - ARDSettingsModelTests *test; |
| - ARDSettingsModelTest() { test = [[ARDSettingsModelTests alloc] init]; } |
| -}; |
| - |
| -TEST_F(ARDSettingsModelTest, DefaultMediaFromStore) { |
| - @autoreleasepool { |
| - [test testDefaultMediaFromStore]; |
| - } |
| -} |
| - |
| -TEST_F(ARDSettingsModelTest, StoringInvalidConstraintsReturnsNo) { |
| - @autoreleasepool { |
| - [test testStoringInavlidConstraintReturnsNo]; |
| - } |
| -} |
| - |
| -TEST_F(ARDSettingsModelTest, WidthConstraintFromStore) { |
| - @autoreleasepool { |
| - [test testWidthConstraintFromStore]; |
| - } |
| -} |
| - |
| -TEST_F(ARDSettingsModelTest, HeightConstraintFromStore) { |
| - @autoreleasepool { |
| - [test testHeightConstraintFromStore]; |
| - } |
| -} |
| - |
| -TEST_F(ARDSettingsModelTest, ConstratintIsNil) { |
| - @autoreleasepool { |
| - [test testConstraintComponentIsNilWhenInvalidConstraintString]; |
| - } |
| -} |
| - |
| -TEST_F(ARDSettingsModelTest, DictionaryIsNil) { |
| - @autoreleasepool { |
| - [test testConstraintsDictionaryIsNilWhenInvalidConstraintString]; |
| - } |
| -} |