Skip to content

Commit

Permalink
Internal change
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 312085611
  • Loading branch information
Nobody authored and andrewoverton committed May 18, 2020
1 parent e479b36 commit 7071680
Show file tree
Hide file tree
Showing 20 changed files with 429 additions and 373 deletions.
33 changes: 33 additions & 0 deletions components/ActionSheet/examples/ActionSheetTypicalUseExample.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ @interface ActionSheetTypicalUseExampleViewController
: UIViewController <MDCActionSheetControllerDelegate>

@property(nonatomic, strong) MDCButton *showButton;
@property(nonatomic, strong) MDCActionSheetController *actionSheet;
@property(nonatomic, strong) id<MDCContainerScheming> containerScheme;

@end
Expand Down Expand Up @@ -92,6 +93,7 @@ - (void)showActionSheet {
[actionSheet addAction:emailAction];
[actionSheet applyThemeWithScheme:self.containerScheme];
actionSheet.delegate = self;
self.actionSheet = actionSheet;
[self presentViewController:actionSheet animated:YES completion:nil];
}

Expand All @@ -113,3 +115,34 @@ + (NSDictionary *)catalogMetadata {
}

@end

@implementation ActionSheetTypicalUseExampleViewController (SnapshotTestingByConvention)

- (void)testDefaults {
// Given
[self resetStates];
MDCContainerScheme *containerScheme = [[MDCContainerScheme alloc] init];
self.containerScheme = containerScheme;

// When
[self showActionSheet];
}

- (void)testDynamic201907ColorScheme {
// Given
[self resetStates];
MDCContainerScheme *containerScheme = [[MDCContainerScheme alloc] init];
containerScheme.colorScheme =
[[MDCSemanticColorScheme alloc] initWithDefaults:MDCColorSchemeDefaultsMaterial201907];
self.containerScheme = containerScheme;

// When
[self showActionSheet];
}

- (void)resetStates {
[self.actionSheet dismissViewControllerAnimated:NO completion:nil];
self.actionSheet = nil;
}

@end
12 changes: 12 additions & 0 deletions components/Banner/examples/AppBarBannerExample.m
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,18 @@ @implementation AppBarBannerExample (SnapshotTestingByConvention)
};
}

- (void)testDynamic201907ColorScheme {
// Given
MDCContainerScheme *containerScheme = [[MDCContainerScheme alloc] init];
containerScheme.colorScheme =
[[MDCSemanticColorScheme alloc] initWithDefaults:MDCColorSchemeDefaultsMaterial201907];
self.containerScheme = containerScheme;

// When
[self.appBarViewController applyPrimaryThemeWithScheme:_containerScheme];
[self showBanner];
}

@end

#pragma mark - Typical application code (not Material-specific)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,17 @@ - (void)testFabHidden {
[self.bottomBarView setFloatingButtonHidden:YES animated:NO];
}

- (void)testDynamic201907ColorSchemeWithCenteredFab {
// Given
[self resetTests];
self.colorScheme =
[[MDCSemanticColorScheme alloc] initWithDefaults:MDCColorSchemeDefaultsMaterial201907];

// When
[self.bottomBarView setFloatingButtonPosition:MDCBottomAppBarFloatingButtonPositionCenter
animated:NO];
}

- (void)resetTests {
[self.bottomBarView setFloatingButtonPosition:MDCBottomAppBarFloatingButtonPositionCenter
animated:NO];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,27 @@ - (void)bottomNavigationBar:(nonnull MDCBottomNavigationBar *)bottomNavigationBa
}

@end

@implementation BottomNavigationTypicalUseExample (SnapshotTestingByConvention)

- (void)testDefaults {
// Given
MDCContainerScheme *containerScheme = [[MDCContainerScheme alloc] init];
self.containerScheme = containerScheme;

// When
[self.bottomNavBar applyPrimaryThemeWithScheme:self.containerScheme];
}

- (void)testDynamic201907ColorScheme {
// Given
MDCContainerScheme *containerScheme = [[MDCContainerScheme alloc] init];
containerScheme.colorScheme =
[[MDCSemanticColorScheme alloc] initWithDefaults:MDCColorSchemeDefaultsMaterial201907];
self.containerScheme = containerScheme;

// When
[self.bottomNavBar applyPrimaryThemeWithScheme:self.containerScheme];
}

@end
48 changes: 48 additions & 0 deletions components/Buttons/examples/ButtonsTypicalUseExample.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@
static const CGSize kMinimumAccessibleButtonSize = {64.0, 48.0};

@interface ButtonsTypicalUseExample ()
@property(nonatomic, strong) MDCButton *containedButton;
@property(nonatomic, strong) MDCButton *disabledContainedButton;
@property(nonatomic, strong) MDCButton *textButton;
@property(nonatomic, strong) MDCButton *disabledTextButton;
@property(nonatomic, strong) MDCButton *outlinedButton;
@property(nonatomic, strong) MDCButton *disabledOutlinedButton;
@property(nonatomic, strong) MDCFloatingButton *floatingButton;
@end

Expand Down Expand Up @@ -65,6 +71,7 @@ - (void)viewDidLoad {
[containedButton addTarget:self
action:@selector(didTap:)
forControlEvents:UIControlEventTouchUpInside];
self.containedButton = containedButton;
[self.view addSubview:containedButton];

// Disabled contained button
Expand All @@ -77,6 +84,7 @@ - (void)viewDidLoad {
action:@selector(didTap:)
forControlEvents:UIControlEventTouchUpInside];
[disabledContainedButton setEnabled:NO];
self.disabledContainedButton = disabledContainedButton;
[self.view addSubview:disabledContainedButton];

// Text button
Expand All @@ -94,6 +102,7 @@ - (void)viewDidLoad {
[textButton addTarget:self
action:@selector(didTap:)
forControlEvents:UIControlEventTouchUpInside];
self.textButton = textButton;
[self.view addSubview:textButton];

// Disabled Text button
Expand All @@ -106,6 +115,7 @@ - (void)viewDidLoad {
action:@selector(didTap:)
forControlEvents:UIControlEventTouchUpInside];
[disabledTextButton setEnabled:NO];
self.disabledTextButton = disabledTextButton;
[self.view addSubview:disabledTextButton];

// Outlined button
Expand All @@ -124,6 +134,7 @@ - (void)viewDidLoad {
[outlinedButton addTarget:self
action:@selector(didTap:)
forControlEvents:UIControlEventTouchUpInside];
self.outlinedButton = outlinedButton;
[self.view addSubview:outlinedButton];

// Disabled outlined button
Expand All @@ -136,6 +147,7 @@ - (void)viewDidLoad {
action:@selector(didTap:)
forControlEvents:UIControlEventTouchUpInside];
[disabledOutlinedButton setEnabled:NO];
self.disabledOutlinedButton = disabledOutlinedButton;
[self.view addSubview:disabledOutlinedButton];

// Floating action button
Expand Down Expand Up @@ -214,3 +226,39 @@ - (void)viewDidAppear:(BOOL)animated {
}

@end

@implementation ButtonsTypicalUseExample (SnapshotTestingByConvention)

- (void)testDefaults {
// Given
MDCContainerScheme *containerScheme = [[MDCContainerScheme alloc] init];
self.containerScheme = containerScheme;

// When
[self.containedButton applyContainedThemeWithScheme:self.containerScheme];
[self.disabledContainedButton applyContainedThemeWithScheme:self.containerScheme];
[self.textButton applyTextThemeWithScheme:self.containerScheme];
[self.disabledTextButton applyTextThemeWithScheme:self.containerScheme];
[self.outlinedButton applyOutlinedThemeWithScheme:self.containerScheme];
[self.disabledOutlinedButton applyOutlinedThemeWithScheme:self.containerScheme];
[self.floatingButton applySecondaryThemeWithScheme:self.containerScheme];
}

- (void)testDynamic201907ColorScheme {
// Given
MDCContainerScheme *containerScheme = [[MDCContainerScheme alloc] init];
containerScheme.colorScheme =
[[MDCSemanticColorScheme alloc] initWithDefaults:MDCColorSchemeDefaultsMaterial201907];
self.containerScheme = containerScheme;

// When
[self.containedButton applyContainedThemeWithScheme:self.containerScheme];
[self.disabledContainedButton applyContainedThemeWithScheme:self.containerScheme];
[self.textButton applyTextThemeWithScheme:self.containerScheme];
[self.disabledTextButton applyTextThemeWithScheme:self.containerScheme];
[self.outlinedButton applyOutlinedThemeWithScheme:self.containerScheme];
[self.disabledOutlinedButton applyOutlinedThemeWithScheme:self.containerScheme];
[self.floatingButton applySecondaryThemeWithScheme:self.containerScheme];
}

@end
17 changes: 17 additions & 0 deletions components/Buttons/examples/FloatingButtonTypicalUseExample.m
Original file line number Diff line number Diff line change
Expand Up @@ -193,3 +193,20 @@ + (NSDictionary *)catalogMetadata {
}

@end

@implementation FloatingButtonTypicalUseExample (SnapshotTestingByConvention)

- (void)testDynamic201907ColorScheme {
// Given
MDCContainerScheme *containerScheme = [[MDCContainerScheme alloc] init];
containerScheme.colorScheme =
[[MDCSemanticColorScheme alloc] initWithDefaults:MDCColorSchemeDefaultsMaterial201907];
self.containerScheme = containerScheme;

// When
[self.miniFloatingButton applySecondaryThemeWithScheme:self.containerScheme];
[self.largeIconFloatingButton applySecondaryThemeWithScheme:self.containerScheme];
[self.largeIconFloatingButton applySecondaryThemeWithScheme:self.containerScheme];
}

@end
Loading

0 comments on commit 7071680

Please sign in to comment.