Created
July 11, 2013 05:28
-
-
Save damondouglas/5972747 to your computer and use it in GitHub Desktop.
Trying Headless Testing in Dart with Content Shell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PASS | |
1 PASS Expectation: text says Click Me!. | |
All 1 tests passed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open "/Applications/dart/chromium/Content Shell.app" --args --dump-render-tree web/headless.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:html'; | |
void main() { | |
query("#sample_text_id") | |
..text = "Click me!" | |
..onClick.listen(reverseText); | |
} | |
void reverseText(MouseEvent event) { | |
var text = query("#sample_text_id").text; | |
var buffer = new StringBuffer(); | |
for (int i = text.length - 1; i >= 0; i--) { | |
buffer.write(text[i]); | |
} | |
query("#sample_text_id").text = buffer.toString(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Headless</title> | |
<link rel="stylesheet" href="headless.css"> | |
</head> | |
<body> | |
<h1>Headless</h1> | |
<p>Hello world from Dart!</p> | |
<div id="sample_container_id"> | |
<p id="sample_text_id"></p> | |
</div> | |
<script type="application/dart" src="headlesstest.dart"></script> | |
<script src="packages/browser/dart.js"></script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:unittest/unittest.dart'; | |
import 'package:unittest/html_config.dart'; | |
import 'dart:html'; | |
import 'headless.dart' as app; | |
void main() { | |
useHtmlConfiguration(); | |
app.main(); | |
var sample_text = query("#sample_text_id"); | |
test('text says Click Me!', (){ | |
expect(sample_text.text, equals('Click me!')); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment