material-components_materia.../components/ProgressView/tests/snapshot/MDCProgressViewCornerRadiusSnapshotTests.m
featherless 63bb1a8c9f
[ProgressView] Add cornerRadius API. (#7417)
This new API enables clients to customize the corner radius of the filled portion of the progress view. Clients have requested this functionality via https://github.com/material-components/material-components-ios/issues/5429.

Example usage to create a "rounded progress pill" effect:

```objc
progressView.cornerRadius = CGRectGetHeight(progressView.bounds) / 2;
```

This feature request was requested by client team in service to their brand requirements.

This PR adds an example that demonstrates the new behavior. See the associated snapshot tests for a complete suite of screenshots of the new behavior.

## Screenshots

![Simulator Screen Shot - iPhone 7 - 2019-05-20 at 09 13 17](https://user-images.githubusercontent.com/45670/58024150-89d14600-7adf-11e9-9c94-6eb023c7f48e.png)

Closes https://github.com/material-components/material-components-ios/issues/5429
2019-09-16 09:58:13 -04:00

135 lines
3.2 KiB
Objective-C

// Copyright 2019-present the Material Components for iOS authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#import "MaterialSnapshot.h"
#import "MaterialProgressView.h"
@interface MDCProgressViewCornerRadiusSnapshotTests : MDCSnapshotTestCase
@property(nonatomic, strong) MDCProgressView *progressView;
@end
@implementation MDCProgressViewCornerRadiusSnapshotTests
- (void)setUp {
[super setUp];
// Uncomment below to recreate all the goldens (or add the following line to the specific
// test you wish to recreate the golden for).
// self.recordMode = YES;
self.progressView = [[MDCProgressView alloc] initWithFrame:CGRectMake(0, 0, 100, 10)];
self.progressView.cornerRadius = CGRectGetHeight(self.progressView.bounds) / 2;
}
- (void)tearDown {
self.progressView = nil;
[super tearDown];
}
- (void)generateSnapshotAndVerifyForView:(UIView *)view {
UIView *snapshotView = [view mdc_addToBackgroundView];
[self snapshotVerifyView:snapshotView];
}
#pragma mark - Tests
- (void)testProgress000LTR {
// When
self.progressView.progress = 0;
// Then
[self generateSnapshotAndVerifyForView:self.progressView];
}
- (void)testProgress000RTL {
// When
[self changeViewToRTL:self.progressView];
self.progressView.progress = 0;
// Then
[self generateSnapshotAndVerifyForView:self.progressView];
}
- (void)testProgress025LTR {
// When
self.progressView.progress = (float).25;
// Then
[self generateSnapshotAndVerifyForView:self.progressView];
}
- (void)testProgress025RTL {
// When
[self changeViewToRTL:self.progressView];
self.progressView.progress = (float).25;
// Then
[self generateSnapshotAndVerifyForView:self.progressView];
}
- (void)testProgress065LTR {
// When
self.progressView.progress = (float).65;
// Then
[self generateSnapshotAndVerifyForView:self.progressView];
}
- (void)testProgress065RTL {
// When
[self changeViewToRTL:self.progressView];
self.progressView.progress = (float).65;
// Then
[self generateSnapshotAndVerifyForView:self.progressView];
}
- (void)testProgress097LTR {
// When
self.progressView.progress = (float).97;
// Then
[self generateSnapshotAndVerifyForView:self.progressView];
}
- (void)testProgress097RTL {
// When
[self changeViewToRTL:self.progressView];
self.progressView.progress = (float).97;
// Then
[self generateSnapshotAndVerifyForView:self.progressView];
}
- (void)testProgress100LTR {
// When
self.progressView.progress = 1;
// Then
[self generateSnapshotAndVerifyForView:self.progressView];
}
- (void)testProgress100RTL {
// When
[self changeViewToRTL:self.progressView];
self.progressView.progress = 1;
// Then
[self generateSnapshotAndVerifyForView:self.progressView];
}
@end