Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Unified Diff: webrtc/examples/objc/AppRTCMobile/tests/ARDMediaConstraintsModelTests.mm

Issue 2462623002: Add setting to AppRTCMobile for iOS, that can change capture resolution. (Closed)
Patch Set: Add check to make sure only available constraint is being stored. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/examples/objc/AppRTCMobile/ios/ARDVideoCallViewController.m ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/examples/objc/AppRTCMobile/tests/ARDMediaConstraintsModelTests.mm
diff --git a/webrtc/examples/objc/AppRTCMobile/tests/ARDMediaConstraintsModelTests.mm b/webrtc/examples/objc/AppRTCMobile/tests/ARDMediaConstraintsModelTests.mm
new file mode 100644
index 0000000000000000000000000000000000000000..6a2f76cdaad07cd020dfa1e88e6052f312911f1a
--- /dev/null
+++ b/webrtc/examples/objc/AppRTCMobile/tests/ARDMediaConstraintsModelTests.mm
@@ -0,0 +1,159 @@
+/*
+ * Copyright 2016 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#import <Foundation/Foundation.h>
+#import <OCMock/OCMock.h>
+#import "ARDMediaConstraintsModel+Private.h"
+#import "ARDMediaConstraintsSettingsStore.h"
+#import "WebRTC/RTCMediaConstraints.h"
+#include "webrtc/base/gunit.h"
+
+
+@interface ARDMediaConstraintsModelTests : NSObject {
+ ARDMediaConstraintsModel *_model;
+}
+
+- (void)testStoringInavlidConstraintReturnsNo;
+- (void)testDefaultMediaFromStore;
+- (void)testWidthConstraintFromStore;
+- (void)testHeightConstraintFromStore;
+
+@end
+
+@implementation ARDMediaConstraintsModelTests
+
+- (instancetype)init {
+ self = [super init];
+ if (self) {
+ _model = [[ARDMediaConstraintsModel alloc] init];
+ }
+ return self;
+}
+
+- (id)setupMockStoreWithMediaConstraintString:(NSString *)constraintString {
+ id storeMock = [OCMockObject mockForClass:[ARDMediaConstraintsSettingsStore class]];
+ [([[storeMock stub] andReturn:constraintString]) videoResolutionConstraintsSetting];
+
+ id partialMock = [OCMockObject partialMockForObject:_model];
+ [[[partialMock stub] andReturn:storeMock] settingsStore];
+
+ return storeMock;
+}
+
+- (void)testDefaultMediaFromStore {
+ // given
+ id storeMock = [self setupMockStoreWithMediaConstraintString:nil];
+
+ [[storeMock expect] setVideoResolutionConstraintsSetting:@"640x480"];
+
+ // when
+ NSString *string = [_model currentVideoResoultionConstraintFromStore];
+
+ // then
+ EXPECT_TRUE([string isEqualToString:@"640x480"]);
+ [storeMock verify];
+}
+
+- (void)testStoringInavlidConstraintReturnsNo {
+ // given
+ id storeMock = [self setupMockStoreWithMediaConstraintString:@"960x480"];
+
+ // when
+ BOOL result = [_model storeVideoResoultionConstraint:@"960x480"];
+
+ // then
+ EXPECT_TRUE(result != YES);
magjed_webrtc 2016/11/01 12:06:09 nit: Can we do EXPECT_FALSE(result) instead?
daniela-webrtc 2016/11/01 14:43:32 Great catch! That slipped (bad habit of comparing
+}
+
+- (void)testWidthConstraintFromStore {
+ // given
+ [self setupMockStoreWithMediaConstraintString:@"1270x480"];
+
+ // when
+ NSString *width = [_model currentVideoResolutionWidthFromStore];
+
+ // then
+ EXPECT_TRUE([width isEqualToString:@"1270"]);
+}
+
+- (void)testHeightConstraintFromStore {
+ // given
+ [self setupMockStoreWithMediaConstraintString:@"960x540"];
+ // when
+ NSString *height = [_model currentVideoResolutionHeightFromStore];
+
+ // then
+ EXPECT_TRUE([height isEqualToString:@"540"]);
+}
+
+- (void)testConstraintComponentIsNilWhenInvalidConstraintString {
+ // given
+ [self setupMockStoreWithMediaConstraintString:@"invalid"];
+
+ // when
+ NSString *width = [_model currentVideoResolutionWidthFromStore];
+
+ // then
+ EXPECT_TRUE(width == nil);
+}
+
+- (void)testConstraintsDictionaryIsNilWhenInvalidConstraintString {
+ // given
+ [self setupMockStoreWithMediaConstraintString:@"invalid"];
+
+ // when
+ NSDictionary *constraintsDictionary = [_model currentMediaConstraintFromStoreAsRTCDictionary];
+
+ // then
+ EXPECT_TRUE(constraintsDictionary == nil);
+}
+@end
+
+class ARDMediaConstraintsModelTest : public ::testing::Test {
+ protected:
+ ARDMediaConstraintsModelTests *test;
+ ARDMediaConstraintsModelTest() { test = [[ARDMediaConstraintsModelTests alloc] init]; }
+};
+
+TEST_F(ARDMediaConstraintsModelTest, DefaultMediaFromStore) {
+ @autoreleasepool {
+ [test testDefaultMediaFromStore];
+ }
+}
+
+TEST_F(ARDMediaConstraintsModelTest, StoringInvalidConstraintsReturnsNo) {
+ @autoreleasepool {
+ [test testStoringInavlidConstraintReturnsNo];
+ }
+}
+
+TEST_F(ARDMediaConstraintsModelTest, WidthConstraintFromStore) {
+ @autoreleasepool {
+ [test testWidthConstraintFromStore];
+ }
+}
+
+TEST_F(ARDMediaConstraintsModelTest, HeightConstraintFromStore) {
+ @autoreleasepool {
+ [test testHeightConstraintFromStore];
+ }
+}
+
+TEST_F(ARDMediaConstraintsModelTest, ConstratintIsNil) {
+ @autoreleasepool {
+ [test testConstraintComponentIsNilWhenInvalidConstraintString];
+ }
+}
+
+TEST_F(ARDMediaConstraintsModelTest, DictionaryIsNil) {
+ @autoreleasepool {
+ [test testConstraintsDictionaryIsNilWhenInvalidConstraintString];
+ }
+}
« no previous file with comments | « webrtc/examples/objc/AppRTCMobile/ios/ARDVideoCallViewController.m ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698