From 4ece1f2c5b32a90d06bed7e467d864e6eef18a05 Mon Sep 17 00:00:00 2001 From: Marc Fisher II Date: Wed, 25 Feb 2015 11:41:44 -0800 Subject: [PATCH 1/5] Style updates. --- dart/lib/clock.dart | 27 +++-- dart/lib/html.dart | 35 +++--- dart/lib/objects.dart | 27 +++-- dart/lib/src/annotations.dart | 31 +++--- dart/lib/src/core.dart | 37 ++++--- dart/lib/src/interfaces.dart | 31 +++--- dart/lib/webdriver.dart | 37 ++++--- dart/pubspec.yaml | 4 +- dart/test/html_no_shadow_dom_test.dart | 35 +++--- dart/test/html_no_shadow_dom_test.html | 15 +++ dart/test/html_test.dart | 35 +++--- dart/test/html_test.html | 15 +++ dart/test/page_objects.dart | 27 +++-- dart/test/pageloader_test.dart | 31 +++--- dart/test/webdriver_no_shadow_dom_test.dart | 44 ++++---- .../webdriver_no_shadow_dom_test_page.html | 15 +++ dart/test/webdriver_test.dart | 101 +++++++++--------- dart/test/webdriver_test_page.html | 15 +++ 18 files changed, 301 insertions(+), 261 deletions(-) diff --git a/dart/lib/clock.dart b/dart/lib/clock.dart index fd2d60e5..08a7dc28 100644 --- a/dart/lib/clock.dart +++ b/dart/lib/clock.dart @@ -1,17 +1,16 @@ -/* - * Copyright 2014 Google Inc. 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. - */ +// Copyright 2014 Google Inc. 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. + library pageloader.clock; /// Interface used to abstract away waiting mechanisms. diff --git a/dart/lib/html.dart b/dart/lib/html.dart index 64edb9be..48df94be 100644 --- a/dart/lib/html.dart +++ b/dart/lib/html.dart @@ -1,30 +1,29 @@ -/* - * Copyright 2014 Google Inc. 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. - */ +// Copyright 2014 Google Inc. 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. + /// PageLoader HTML provides the necessary bindings to support using PageLoader /// Objects in tests that run within the browser. library pageloader.html; +import 'dart:collection'; +import 'dart:html'; +import 'dart:mirrors' hide Comment; + import 'clock.dart'; import 'src/core.dart'; import 'src/interfaces.dart'; export 'src/interfaces.dart'; -import 'dart:collection'; -import 'dart:html'; -import 'dart:mirrors' hide Comment; - /// A function that will be executed after [click] and [type] and during /// [waitFor] and [waitForValue] to allow events to be processed. For example /// if using Angular's async test wrapper this should be a function that calls diff --git a/dart/lib/objects.dart b/dart/lib/objects.dart index f57a7862..cd1cc0e3 100644 --- a/dart/lib/objects.dart +++ b/dart/lib/objects.dart @@ -1,17 +1,16 @@ -/* - * Copyright 2014 Google Inc. 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. - */ +// Copyright 2014 Google Inc. 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. + /// PageLoader Objects provides the core interface and annotation definitions /// that should be used within PageLoader Objects. library pageloader.objects; diff --git a/dart/lib/src/annotations.dart b/dart/lib/src/annotations.dart index e9db51aa..99777ed3 100644 --- a/dart/lib/src/annotations.dart +++ b/dart/lib/src/annotations.dart @@ -1,23 +1,22 @@ -/* - * Copyright 2014 Google Inc. 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. - */ -library pageloader.annotations; +// Copyright 2014 Google Inc. 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 'interfaces.dart'; +library pageloader.annotations; import 'dart:collection'; +import 'interfaces.dart'; + class ById implements Finder { final String id; diff --git a/dart/lib/src/core.dart b/dart/lib/src/core.dart index 1c1ce9a4..9ab74153 100644 --- a/dart/lib/src/core.dart +++ b/dart/lib/src/core.dart @@ -1,27 +1,26 @@ -/* - * Copyright 2014 Google Inc. 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. - */ +// Copyright 2014 Google Inc. 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. + library pageloader.core; -import 'annotations.dart'; -import 'interfaces.dart'; -import '../clock.dart'; +import 'dart:collection'; +import 'dart:mirrors'; import 'package:matcher/matcher.dart'; -import 'dart:collection'; -import 'dart:mirrors'; +import '../clock.dart'; +import 'annotations.dart'; +import 'interfaces.dart'; bool _printedWarning = false; diff --git a/dart/lib/src/interfaces.dart b/dart/lib/src/interfaces.dart index 8e9200ba..d8b791ed 100644 --- a/dart/lib/src/interfaces.dart +++ b/dart/lib/src/interfaces.dart @@ -1,23 +1,22 @@ -/* - * Copyright 2014 Google Inc. 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. - */ -library pageloader.interfaces; +// Copyright 2014 Google Inc. 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 'package:matcher/matcher.dart'; +library pageloader.interfaces; import 'dart:collection'; +import 'package:matcher/matcher.dart'; + abstract class Lazy { T call(); } diff --git a/dart/lib/webdriver.dart b/dart/lib/webdriver.dart index 6f718ed6..ba4315a3 100644 --- a/dart/lib/webdriver.dart +++ b/dart/lib/webdriver.dart @@ -1,31 +1,30 @@ -/* - * Copyright 2014 Google Inc. 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. - */ +// Copyright 2014 Google Inc. 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. + /// PageLoader WebDriver provides the necessary bindings to support using /// PageLoader in WebDriver-based tests. library pageloader.webdriver; -import 'clock.dart'; -import 'src/core.dart'; -import 'src/interfaces.dart'; -export 'src/interfaces.dart'; - import 'dart:collection'; import 'dart:io' as io; import 'package:sync_webdriver/sync_webdriver.dart' as wd; +import 'clock.dart'; +import 'src/core.dart'; +import 'src/interfaces.dart'; +export 'src/interfaces.dart'; + class WebDriverPageLoader extends BasePageLoader { WebDriverPageLoaderElement _globalContext; @override diff --git a/dart/pubspec.yaml b/dart/pubspec.yaml index d15f2c0e..5075e449 100644 --- a/dart/pubspec.yaml +++ b/dart/pubspec.yaml @@ -1,5 +1,5 @@ name: pageloader -version: 1.3.2 +version: 1.3.2+1 author: Google Inc. description: > Supports the creation of page objects that can be shared between in-browser tests @@ -9,7 +9,7 @@ environment: sdk: '>=1.8.0 <2.0.0' dependencies: matcher: '^0.11.4+1' - sync_webdriver: '^1.1.4' + sync_webdriver: '^1.1.4+1' dev_dependencies: browser: '^0.10.0+2' path: '^1.3.3' diff --git a/dart/test/html_no_shadow_dom_test.dart b/dart/test/html_no_shadow_dom_test.dart index 933462a2..7d647d15 100644 --- a/dart/test/html_no_shadow_dom_test.dart +++ b/dart/test/html_no_shadow_dom_test.dart @@ -1,27 +1,26 @@ -/* - * Copyright 2014 Google Inc. 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. - */ +// Copyright 2014 Google Inc. 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. library pageloader.test.html_no_shadow_dom; -import 'page_objects.dart'; -import 'pageloader_test.dart' as plt; +import 'dart:html' as html; import 'package:pageloader/html.dart'; -import 'package:unittest/html_enhanced_config.dart'; +import 'package:unittest/html_enhanced_config.dart' + show useHtmlEnhancedConfiguration; import 'package:unittest/unittest.dart'; -import 'dart:html' as html; +import 'page_objects.dart'; +import 'pageloader_test.dart' as plt; void main() { useHtmlEnhancedConfiguration(); diff --git a/dart/test/html_no_shadow_dom_test.html b/dart/test/html_no_shadow_dom_test.html index 2914f9cd..5cb7a4f0 100644 --- a/dart/test/html_no_shadow_dom_test.html +++ b/dart/test/html_no_shadow_dom_test.html @@ -1,5 +1,20 @@ + + diff --git a/dart/test/html_test.dart b/dart/test/html_test.dart index 2d49a979..55776beb 100644 --- a/dart/test/html_test.dart +++ b/dart/test/html_test.dart @@ -1,27 +1,26 @@ -/* - * Copyright 2014 Google Inc. 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. - */ +// Copyright 2014 Google Inc. 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. library pageloader.test.html; -import 'page_objects.dart'; -import 'pageloader_test.dart' as plt; +import 'dart:html' as html; import 'package:pageloader/html.dart'; -import 'package:unittest/html_enhanced_config.dart'; +import 'package:unittest/html_enhanced_config.dart' + show useHtmlEnhancedConfiguration; import 'package:unittest/unittest.dart'; -import 'dart:html' as html; +import 'page_objects.dart'; +import 'pageloader_test.dart' as plt; void main() { useHtmlEnhancedConfiguration(); diff --git a/dart/test/html_test.html b/dart/test/html_test.html index 43f66ada..2fddf408 100644 --- a/dart/test/html_test.html +++ b/dart/test/html_test.html @@ -1,5 +1,20 @@ + + diff --git a/dart/test/page_objects.dart b/dart/test/page_objects.dart index 334ff363..86e1b100 100644 --- a/dart/test/page_objects.dart +++ b/dart/test/page_objects.dart @@ -1,17 +1,16 @@ -/* - * Copyright 2014 Google Inc. 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. - */ +// Copyright 2014 Google Inc. 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. + library pageloader.test.page_objects; import 'package:pageloader/objects.dart'; diff --git a/dart/test/pageloader_test.dart b/dart/test/pageloader_test.dart index c91ce367..6b1d05c5 100644 --- a/dart/test/pageloader_test.dart +++ b/dart/test/pageloader_test.dart @@ -1,25 +1,24 @@ -/* - * Copyright 2014 Google Inc. 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. - */ -library pageloader.test; +// Copyright 2014 Google Inc. 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 'page_objects.dart'; +library pageloader.test; import 'package:matcher/matcher.dart'; import 'package:pageloader/objects.dart'; import 'package:unittest/unittest.dart'; +import 'page_objects.dart'; + PageLoader loader; void runTests() { diff --git a/dart/test/webdriver_no_shadow_dom_test.dart b/dart/test/webdriver_no_shadow_dom_test.dart index eb96a135..5995c644 100644 --- a/dart/test/webdriver_no_shadow_dom_test.dart +++ b/dart/test/webdriver_no_shadow_dom_test.dart @@ -1,27 +1,27 @@ -/* - * Copyright 2014 Google Inc. 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. - */ +// Copyright 2014 Google Inc. 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. library pageloader.test.webdriver_no_shadow_dom; -import 'pageloader_test.dart' as plt; +import 'dart:io'; -import 'package:pageloader/webdriver.dart'; +import 'package:pageloader/webdriver.dart' show WebDriverPageLoader; import 'package:path/path.dart' as path; import 'package:unittest/unittest.dart'; -import 'package:unittest/vm_config.dart'; -import 'package:sync_webdriver/sync_webdriver.dart' hide Platform; -import 'dart:io'; +import 'package:unittest/vm_config.dart' show useVMConfiguration; +import 'package:sync_webdriver/sync_webdriver.dart' + show Capabilities, WebDriver; + +import 'pageloader_test.dart' as plt; void main() { useVMConfiguration(); @@ -53,7 +53,7 @@ String get _testPagePath { return path.toUri(testPagePath).toString(); } -WebDriver _createTestDriver({Map additionalCapabilities}) { +WebDriver _createTestDriver() { Map capabilities = Capabilities.chrome; Map env = Platform.environment; @@ -71,9 +71,5 @@ WebDriver _createTestDriver({Map additionalCapabilities}) { capabilities['chromeOptions'] = chromeOptions; } - if (additionalCapabilities != null) { - capabilities.addAll(additionalCapabilities); - } - return new WebDriver(desired: capabilities); } diff --git a/dart/test/webdriver_no_shadow_dom_test_page.html b/dart/test/webdriver_no_shadow_dom_test_page.html index a66245dd..5162960c 100644 --- a/dart/test/webdriver_no_shadow_dom_test_page.html +++ b/dart/test/webdriver_no_shadow_dom_test_page.html @@ -1,5 +1,20 @@ + + test_page diff --git a/dart/test/webdriver_test.dart b/dart/test/webdriver_test.dart index 13caf388..acb61bc3 100644 --- a/dart/test/webdriver_test.dart +++ b/dart/test/webdriver_test.dart @@ -1,26 +1,27 @@ -/* - * Copyright 2014 Google Inc. 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. - */ +// Copyright 2014 Google Inc. 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. library pageloader.test.webdriver; -import 'pageloader_test.dart' as plt; +import 'dart:io'; -import 'package:pageloader/webdriver.dart'; +import 'package:pageloader/webdriver.dart' show WebDriverPageLoader; import 'package:path/path.dart' as path; import 'package:unittest/unittest.dart'; -import 'package:unittest/vm_config.dart'; -import 'package:sync_webdriver/sync_webdriver.dart' hide Platform; +import 'package:unittest/vm_config.dart' show useVMConfiguration; +import 'package:sync_webdriver/sync_webdriver.dart' + show Capabilities, WebDriver; + +import 'pageloader_test.dart' as plt; void main() { useVMConfiguration(); @@ -28,52 +29,46 @@ void main() { WebDriver driver; setUp(() { - driver = freshDriver; - driver.url = testPagePath; + driver = _createTestDriver(); + driver.url = _testPagePath; plt.loader = new WebDriverPageLoader(driver); }); + tearDown(() { + driver.quit(); + plt.loader = null; + }); + plt.runTests(); +} - // This test needs to be last to properly close the browser. - test('one-time teardown', () { - closeDriver(); - }); +String get _testPagePath { + var testPagePath = path.join('test', 'webdriver_test_page.html'); + testPagePath = path.absolute(testPagePath); + if (!FileSystemEntity.isFileSync(testPagePath)) { + throw new Exception('Could not find the test file at "$testPagePath".' + ' Make sure you are running tests from the root of the project.'); + } + return path.toUri(testPagePath).toString(); } -String get testPagePath => - path.toUri(path.absolute('webdriver_test_page.html')).toString(); +WebDriver _createTestDriver() { + Map capabilities = Capabilities.chrome; + Map env = Platform.environment; -WebDriver _driver; + Map chromeOptions = {}; -WebDriver get freshDriver { - if (_driver != null) { - try { - Window firstWindow = null; + if (env['CHROMEDRIVER_BINARY'] != null) { + chromeOptions['binary'] = env['CHROMEDRIVER_BINARY']; + } - for (Window window in _driver.windows) { - if (firstWindow == null) { - firstWindow = window; - } else { - _driver.switchTo.window(window); - _driver.close(); - } - } - _driver.switchTo.window(firstWindow); - _driver.url = 'about:'; - } catch (e) { - closeDriver(); - } + if (env['CHROMEDRIVER_ARGS'] != null) { + chromeOptions['args'] = env['CHROMEDRIVER_ARGS'].split(' '); } - if (_driver == null) { - _driver = new WebDriver(desired: Capabilities.chrome); + + if (chromeOptions.isNotEmpty) { + capabilities['chromeOptions'] = chromeOptions; } - return _driver; -} -void closeDriver() { - try { - _driver.quit(); - } catch (e) {} - _driver = null; + return new WebDriver(desired: capabilities); } diff --git a/dart/test/webdriver_test_page.html b/dart/test/webdriver_test_page.html index 928d6908..0ed13e94 100644 --- a/dart/test/webdriver_test_page.html +++ b/dart/test/webdriver_test_page.html @@ -1,5 +1,20 @@ + + test_page From 657f9ffe103f93ae2ea482654134d653f4ce7adf Mon Sep 17 00:00:00 2001 From: Marc Fisher II Date: Wed, 25 Feb 2015 12:43:00 -0800 Subject: [PATCH 2/5] More style cleanup. --- dart/tool/travis.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dart/tool/travis.sh b/dart/tool/travis.sh index fface4c3..7c4b277a 100755 --- a/dart/tool/travis.sh +++ b/dart/tool/travis.sh @@ -34,7 +34,7 @@ dartanalyzer --fatal-warnings \ if [ "$TRAVIS" ]; then # Start chromedriver. chromedriver --port=4444 --url-base=wd/hub & - + # Run test/webdriver_no_shadow_dom_test.dart. dart test/webdriver_no_shadow_dom_test.dart fi From 8dc412469d384a8d87ace379c8d0ed662514e2da Mon Sep 17 00:00:00 2001 From: Marc Fisher II Date: Fri, 27 Feb 2015 10:21:14 -0800 Subject: [PATCH 3/5] Change interface for @InShadowDom. --- dart/lib/html.dart | 1 + dart/lib/src/annotations.dart | 43 ++++++++++++++++++++++++++++++----- dart/test/page_objects.dart | 2 +- 3 files changed, 39 insertions(+), 7 deletions(-) diff --git a/dart/lib/html.dart b/dart/lib/html.dart index 48df94be..f66c8db0 100644 --- a/dart/lib/html.dart +++ b/dart/lib/html.dart @@ -15,6 +15,7 @@ /// Objects in tests that run within the browser. library pageloader.html; +import 'dart:async' show Future; import 'dart:collection'; import 'dart:html'; import 'dart:mirrors' hide Comment; diff --git a/dart/lib/src/annotations.dart b/dart/lib/src/annotations.dart index 99777ed3..aae175d9 100644 --- a/dart/lib/src/annotations.dart +++ b/dart/lib/src/annotations.dart @@ -90,21 +90,52 @@ class EnsureTag implements Finder { } class InShadowDom implements Finder { - final Finder finder; + final Finder of; + final Finder find; - const InShadowDom([this.finder]); + /// Traverses into the shadow dom of the elements found by [of] (or of the + /// current scope if [of] not provided), and then finds elements using [find] + /// if provided. + const InShadowDom({this.of, this.find}); @override List findElements(PageLoaderElement context) { - if (finder == null) { - return new UnmodifiableListView([context.shadowRoot]); + Iterable candidates; + if (of != null) { + candidates = of.findElements(context); } else { - return finder.findElements(context.shadowRoot); + candidates = [context]; } + candidates = candidates.map((candidate) => candidate.shadowRoot); + if (find != null) { + var newCandidates = new Set(); + for (var candidate in candidates) { + newCandidates.addAll(find.findElements(candidate)); + } + candidates = newCandidates; + } + return new UnmodifiableListView(candidates); } @override - String toString() => '@InShadowDom(${finder == null ? '' : finder})'; + String toString() { + var buffer = new StringBuffer('@InShadowDom('); + bool commaNeeded = false; + if (of != null) { + buffer + ..write('of: ') + ..write(of); + commaNeeded = true; + } + if (find != null) { + if (commaNeeded) buffer.write(', '); + buffer + ..write('find: ') + ..write(find); + } + buffer.write(')'); + return buffer.toString(); + } } class Returns { diff --git a/dart/test/page_objects.dart b/dart/test/page_objects.dart index 86e1b100..04e43ba4 100644 --- a/dart/test/page_objects.dart +++ b/dart/test/page_objects.dart @@ -328,7 +328,7 @@ class PageForChainTest { @Chain(const [ const ByClass('outer-div'), const ByTagName('a-custom-tag'), - const InShadowDom(const ById('inner')) + const InShadowDom(find: const ById('inner')) ]) PageLoaderElement innerShadow; From f5aedca827697aca31496a96dc1fda114a34f583 Mon Sep 17 00:00:00 2001 From: Marc Fisher II Date: Fri, 27 Feb 2015 10:22:55 -0800 Subject: [PATCH 4/5] Update version number. --- dart/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dart/pubspec.yaml b/dart/pubspec.yaml index 5075e449..5c0b990d 100644 --- a/dart/pubspec.yaml +++ b/dart/pubspec.yaml @@ -1,5 +1,5 @@ name: pageloader -version: 1.3.2+1 +version: 1.3.3 author: Google Inc. description: > Supports the creation of page objects that can be shared between in-browser tests From 859efb22ae9970ff8d023979084c73a1aa665211 Mon Sep 17 00:00:00 2001 From: Marc Fisher II Date: Fri, 27 Feb 2015 10:23:27 -0800 Subject: [PATCH 5/5] Update version number. --- dart/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dart/pubspec.yaml b/dart/pubspec.yaml index 5c0b990d..1973adc4 100644 --- a/dart/pubspec.yaml +++ b/dart/pubspec.yaml @@ -1,5 +1,5 @@ name: pageloader -version: 1.3.3 +version: 1.4.0 author: Google Inc. description: > Supports the creation of page objects that can be shared between in-browser tests