8 Commits

Author SHA1 Message Date
Yarden Eitan
a8d3794de3
[NavigationDrawer] Added a state system to the Nav Drawer (#5520)
Context:
To allow us to create APIs for our users to set different appearances based on the different states the drawer can be in, we need to create an initial state system.

The Problem:
Without defining a state for our drawer, we won't be able to differentiate between different presentations the drawer may be in, and then alter the drawer's appearance effectively.

The Fix:
Provide a state enum as part of MDCBottomDrawerController, that is read only, and is set using a delegate that is initially set by the internal implementation.

Testing:
Unit Tests + Tested on an iPhone X and iPhone 7 with smaller and bigger preferredContentSize to imitate different states.

Related Bugs:
Closes #5524
2018-10-30 13:27:17 +02:00
Cody Weaver
690b81efdd
[NavigationDrawer] Test content height surplus and scrolls to reveal (#5466)
### Context
NavigationDrawer is missing unit test. One of the _heavy lifting_ functions is `cacheLayoutCalculation`, which has many side effects. One of those side effects is setting the `contentHeightSurplus`. `contentHeightSurplus` effects `scrollsToReveal` so those test were also added. 

**_Note:_** I didn't add any comments in the test but those may be necessary to give future maintainers context on why the test are a given result.

### Related issues
#4911 
### Related PR
#5465
2018-10-22 17:11:56 -04:00
Cody Weaver
b2c690d209
[NavigationDrawer] Add test for contentHeaderTopInset and presentingViewBounds (#5465)
### Content
NavigationDrawer is missing unit test. One of the _heavy lifting_ functions is `cacheLayoutCalculation`, which has many side effects. One of those side effects is setting the `contentHeaderTopInset`. In cacheLayoutCalculations there is two paths to set `contentHeaderTopInset` one is with scrollable content and one is without scrollable content. If the content isn't scrollable then the `contentHeaderTopInset` is the size of the `presentingViewBounds.size.height` minus the `headerViewController.preferredContentSize.height` and the `contentViewController.preferredContentSize.height`. If the content is scrollable then the `contentHeaderTopInset` is the size of the `presentingViewBounds` * `initialDrawerFactor`.  

### Work in the PR
Test `presentingViewBounds`

Test `contentHeaderTopInset` 
-  Scrollable
   - With large headerViewController
   - With large contentViewController
   - With large contentViewController and headerViewController
- Non-scrollable
  - With only a headerViewController
  - With only a contentViewController
  - With both a contentViewController and a headerViewController
  - With no contentViewController or headerViewController

### Remaining Work
For `cacheLayoutCalculations` we still need to test `contentHeightSurplus`
### Related issues
#4911
2018-10-22 15:20:18 -04:00
Cody Weaver
f925ce48db
[NavigationDrawer] Add unit test for height related properties (#5461)
### Context
We currently are missing a lot unit test for NavigationDrawer. In order to keep the PR's manageable I have decided to break them up into related groups. This group is the two properties that look at the headerViewControllers.preferredContentSize.height and tests those two.
### The problem
We are missing a lot of unit test for NavigationDrawer
### The fix
Add test for `topHeaderHeight` and `contentHeaderHeight`

### Bugs
Related to #4911
2018-10-19 16:05:34 -04:00
rami-a
70457a398a
[NavigationDrawer] Add Color Themer support (#5458)
### The problem

BottomDrawer previously had no color themer support

### The fix

This change adds a color themer for BottomDrawer. Additionally this adds unit tests and updates the example to use the color themer. The guidelines indicate the content and header should utilize the semantic surface color, so that is what the themer applies to the BottomDrawer. 

**Note:** The drawer should be configured with its header and content ViewControllers before applying the theme.

### Related issues

Closes #4910 

### Code snippet

#### Swift
```
    let bottomDrawerViewController = MDCBottomDrawerViewController()
    bottomDrawerViewController.contentViewController = contentViewController
    bottomDrawerViewController.headerViewController = headerViewController
    MDCBottomDrawerColorThemer.applySemanticColorScheme(colorScheme,
                                                        toBottomDrawer: bottomDrawerViewController)
```

#### ObjC
```
MDCBottomDrawerViewController *bottomDrawer = [[MDCBottomDrawerViewController alloc] init];
bottomDrawer.contentViewController = contentViewController
bottomDrawer.headerViewController = headerViewController
[MDCBottomDrawerColorThemer applySemanticColorScheme:self.colorScheme
                                      toBottomDrawer:bottomDrawer];
```
2018-10-19 15:36:58 -04:00
Cody Weaver
596f72b395
[NavigationDrawer] Add Fakes files for tests (#5453)
### Context
In #5423 my thinking was that we would need to test MDCBottomDrawerViewController but majority of the test are going to be related to MDCBottomDrawerContainerViewController. We may still want to test MDCBottomDrawerViewController so that is why I haven't completely removed that file for tests. But, we need fakes in a couple places so this adds _Fakes_ files so that code can be shared.

### The problem
We need fakes for test in MaterialNavigationDrawer because we can't present and that code should be shared.

### The fix
Add a `MDCNavigationDrawerFakes` files so we can have fakes and they can be shared across test files.

### Related bugs
#4911
2018-10-19 12:31:27 -04:00
Cody Weaver
90d84a4bf5
[NavigationDrawer] Add scroll view test (#5445)
### Context
Add basic test for the scroll view. Related to #4911
2018-10-18 14:22:47 -04:00
Cody Weaver
b18f9987b6
[NavigationDrawer] Setup for tests (#5423)
Context
Set up the everything to start work on unit test for Navigation Drawer. In order to make small changes that are easier to review this sets up the files to get ready for test. This will allow us to work in tandem on unit test for this component once the files are in place.

The problem
MDCNavigationDrawer doesn't have any unit test

The fix
This adds the files to the build file and basic setup to add tests

Related bug
b/117175875
2018-10-15 20:25:44 -04:00