Skip to content

Commit 62e0fa5

Browse files
committed
Merge branch 'master' of github.com:angular/material2
2 parents b434d54 + 8da751c commit 62e0fa5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+2596
-294
lines changed

e2e/components/menu/menu-page.ts

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import ElementFinder = protractor.ElementFinder;
2+
3+
export class MenuPage {
4+
5+
constructor() {
6+
browser.get('/menu');
7+
}
8+
9+
menu() { return element(by.css('.md-menu')); }
10+
11+
trigger() { return element(by.id('trigger')); }
12+
13+
triggerTwo() { return element(by.id('trigger-two')); }
14+
15+
body() { return element(by.tagName('body')); }
16+
17+
items(index: number) {
18+
return element.all(by.css('[md-menu-item]')).get(index);
19+
}
20+
21+
textArea() { return element(by.id('text')); }
22+
23+
beforeTrigger() { return element(by.id('before-t')); }
24+
25+
aboveTrigger() { return element(by.id('above-t')); }
26+
27+
combinedTrigger() { return element(by.id('combined-t')); }
28+
29+
beforeMenu() { return element(by.css('.md-menu.before')); }
30+
31+
aboveMenu() { return element(by.css('.md-menu.above')); }
32+
33+
combinedMenu() { return element(by.css('.md-menu.combined')); }
34+
35+
expectMenuPresent(expected: boolean) {
36+
return browser.isElementPresent(by.css('.md-menu')).then((isPresent) => {
37+
expect(isPresent).toBe(expected);
38+
});
39+
}
40+
41+
expectMenuLocation(el: ElementFinder, {x,y}: {x: number, y: number}) {
42+
el.getLocation().then((loc) => {
43+
expect(loc.x).toEqual(x);
44+
expect(loc.y).toEqual(y);
45+
});
46+
}
47+
48+
expectMenuAlignedWith(el: ElementFinder, id: string) {
49+
element(by.id(id)).getLocation().then((loc) => {
50+
this.expectMenuLocation(el, {x: loc.x, y: loc.y});
51+
});
52+
}
53+
54+
getResultText() {
55+
return this.textArea().getText();
56+
}
57+
}

e2e/components/menu/menu.e2e.ts

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
import { MenuPage } from './menu-page';
2+
3+
describe('menu', () => {
4+
let page: MenuPage;
5+
6+
beforeEach(function() {
7+
page = new MenuPage();
8+
});
9+
10+
it('should open menu when the trigger is clicked', () => {
11+
page.expectMenuPresent(false);
12+
page.trigger().click();
13+
14+
page.expectMenuPresent(true);
15+
expect(page.menu().getText()).toEqual("One\nTwo\nThree");
16+
});
17+
18+
it('should close menu when area outside menu is clicked', () => {
19+
page.trigger().click();
20+
page.body().click();
21+
page.expectMenuPresent(false);
22+
});
23+
24+
it('should close menu when menu item is clicked', () => {
25+
page.trigger().click();
26+
page.items(0).click();
27+
page.expectMenuPresent(false);
28+
});
29+
30+
it('should run click handlers on regular menu items', () => {
31+
page.trigger().click();
32+
page.items(0).click();
33+
expect(page.getResultText()).toEqual('one');
34+
35+
page.trigger().click();
36+
page.items(1).click();
37+
expect(page.getResultText()).toEqual('two');
38+
});
39+
40+
it('should run not run click handlers on disabled menu items', () => {
41+
page.trigger().click();
42+
page.items(2).click();
43+
expect(page.getResultText()).toEqual('');
44+
});
45+
46+
it('should support multiple triggers opening the same menu', () => {
47+
page.triggerTwo().click();
48+
expect(page.menu().getText()).toEqual("One\nTwo\nThree");
49+
page.expectMenuAlignedWith(page.menu(), 'trigger-two');
50+
51+
page.body().click();
52+
page.expectMenuPresent(false);
53+
54+
page.trigger().click();
55+
expect(page.menu().getText()).toEqual("One\nTwo\nThree");
56+
page.expectMenuAlignedWith(page.menu(), 'trigger');
57+
58+
page.body().click();
59+
page.expectMenuPresent(false);
60+
});
61+
62+
it('should mirror classes on host to menu template in overlay', () => {
63+
page.trigger().click();
64+
page.menu().getAttribute('class').then((classes) => {
65+
expect(classes).toEqual('md-menu custom');
66+
});
67+
});
68+
69+
describe('position - ', () => {
70+
71+
it('should default menu alignment to "after below" when not set', () => {
72+
page.trigger().click();
73+
74+
// menu.x should equal trigger.x, menu.y should equal trigger.y
75+
page.expectMenuAlignedWith(page.menu(), 'trigger');
76+
});
77+
78+
it('should align overlay end to origin end when x-position is "before"', () => {
79+
page.beforeTrigger().click();
80+
page.beforeTrigger().getLocation().then((trigger) => {
81+
82+
// the menu's right corner must be attached to the trigger's right corner.
83+
// menu = 112px wide. trigger = 60px wide. 112 - 60 = 52px of menu to the left of trigger.
84+
// trigger.x (left corner) - 52px (menu left of trigger) = expected menu.x (left corner)
85+
// menu.y should equal trigger.y because only x position has changed.
86+
page.expectMenuLocation(page.beforeMenu(), {x: trigger.x - 52, y: trigger.y});
87+
});
88+
});
89+
90+
it('should align overlay bottom to origin bottom when y-position is "above"', () => {
91+
page.aboveTrigger().click();
92+
page.aboveTrigger().getLocation().then((trigger) => {
93+
94+
// the menu's bottom corner must be attached to the trigger's bottom corner.
95+
// menu.x should equal trigger.x because only y position has changed.
96+
// menu = 64px high. trigger = 20px high. 64 - 20 = 44px of menu extending up past trigger.
97+
// trigger.y (top corner) - 44px (menu above trigger) = expected menu.y (top corner)
98+
page.expectMenuLocation(page.aboveMenu(), {x: trigger.x, y: trigger.y - 44});
99+
});
100+
});
101+
102+
it('should align menu to top left of trigger when "below" and "above"', () => {
103+
page.combinedTrigger().click();
104+
page.combinedTrigger().getLocation().then((trigger) => {
105+
106+
// trigger.x (left corner) - 52px (menu left of trigger) = expected menu.x
107+
// trigger.y (top corner) - 44px (menu above trigger) = expected menu.y
108+
page.expectMenuLocation(page.combinedMenu(), {x: trigger.x - 52, y: trigger.y - 44});
109+
});
110+
});
111+
112+
});
113+
});

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"@angular/platform-browser": "2.0.0-rc.4",
3636
"@angular/platform-browser-dynamic": "2.0.0-rc.4",
3737
"@angular/router": "v3.0.0-alpha.8",
38-
"@angular/forms": "^0.1.0",
38+
"@angular/forms": "^0.2.0",
3939
"core-js": "^2.4.0",
4040
"hammerjs": "^2.0.8",
4141
"rxjs": "5.0.0-beta.6",

src/components/checkbox/checkbox.scss

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,12 +218,13 @@ $_md-checkbox-indeterminate-checked-easing-function: cubic-bezier(0.14, 0, 0, 1)
218218
}
219219

220220
md-checkbox {
221-
&, label {
222-
cursor: pointer;
223-
}
221+
cursor: pointer;
224222
}
225223

226224
.md-checkbox-layout {
225+
// `cursor: inherit` ensures that the wrapper element gets the same cursor as the md-checkbox
226+
// (e.g. pointer by default, regular when disabled), instead of the browser default.
227+
cursor: inherit;
227228
align-items: baseline;
228229
display: inline-flex;
229230
}

src/components/checkbox/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@
2222
"homepage": "https://github.com/angular/material2#readme",
2323
"peerDependencies": {
2424
"@angular2-material/core": "2.0.0-alpha.6-2",
25-
"@angular/forms": "^0.1.0"
25+
"@angular/forms": "^0.2.0"
2626
}
2727
}

src/components/dialog/dialog.spec.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ import {
1313
ChangeDetectorRef,
1414
} from '@angular/core';
1515
import {MdDialog} from './dialog';
16-
import {OVERLAY_PROVIDERS, OVERLAY_CONTAINER_TOKEN} from '@angular2-material/core/overlay/overlay';
16+
import {OVERLAY_PROVIDERS} from '@angular2-material/core/overlay/overlay';
17+
import {OverlayContainer} from '@angular2-material/core/overlay/overlay-container';
1718
import {MdDialogConfig} from './dialog-config';
1819
import {MdDialogRef} from './dialog-ref';
1920

@@ -31,10 +32,14 @@ describe('MdDialog', () => {
3132
addProviders([
3233
OVERLAY_PROVIDERS,
3334
MdDialog,
34-
{provide: OVERLAY_CONTAINER_TOKEN, useFactory: () => {
35-
overlayContainerElement = document.createElement('div');
36-
return overlayContainerElement;
37-
}}
35+
{provide: OverlayContainer, useFactory: () => {
36+
return {
37+
getContainerElement: () => {
38+
overlayContainerElement = document.createElement('div');
39+
return overlayContainerElement;
40+
}
41+
};
42+
}},
3843
]);
3944
});
4045

src/components/input/input.spec.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,25 @@ describe('MdInput', function () {
3535
});
3636
}));
3737

38+
39+
// TODO(kara): update when core/testing adds fix
3840
it('support ngModel', async(() => {
3941
builder.createAsync(MdInputBaseTestController)
4042
.then(fixture => {
4143
fixture.detectChanges();
4244
let instance = fixture.componentInstance;
43-
let component = fixture.debugElement.query(By.directive(MdInput)).componentInstance;
4445
let el: HTMLInputElement = fixture.debugElement.query(By.css('input')).nativeElement;
4546

4647
instance.model = 'hello';
4748
fixture.detectChanges();
48-
expect(el.value).toEqual('hello');
49+
fixture.whenStable().then(() => {
4950

50-
component.value = 'world';
51-
fixture.detectChanges();
52-
expect(el.value).toEqual('world');
51+
// this workaround is temp, see https://github.com/angular/angular/issues/10148
52+
fixture.detectChanges();
53+
fixture.whenStable().then(() => {
54+
expect(el.value).toBe('hello');
55+
});
56+
});
5357
});
5458
}));
5559

@@ -80,7 +84,9 @@ describe('MdInput', function () {
8084

8185
instance.model = 'hello';
8286
fixture.detectChanges();
83-
expect(inputInstance.characterCount).toEqual(5);
87+
fixture.whenStable().then(() => {
88+
expect(inputInstance.characterCount).toEqual(5);
89+
});
8490
});
8591
}));
8692

src/components/input/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@
2424
"homepage": "https://github.com/angular/material2#readme",
2525
"peerDependencies": {
2626
"@angular2-material/core": "2.0.0-alpha.6-2",
27-
"@angular/forms": "^0.1.0"
27+
"@angular/forms": "^0.2.0"
2828
}
2929
}

0 commit comments

Comments
 (0)