Skip to content

Commit

Permalink
Fix editor tests and test_runner
Browse files Browse the repository at this point in the history
Paired with @terrasea

#102
  • Loading branch information
eee-c committed Aug 23, 2015
1 parent c4b0c50 commit 327c509
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 83 deletions.
2 changes: 1 addition & 1 deletion lib/full.dart
Expand Up @@ -36,7 +36,7 @@ class Full {
Stream get onPreviewChange => ice.onPreviewChange;
Future get editorReady => ice.editorReady;
String get content => ice.content;
String set content(data) => ice.content = data;
void set content(data) => ice.content = data;

String get lineContent => ice.lineContent;
int get lineNumber => ice.lineNumber;
Expand Down
77 changes: 30 additions & 47 deletions test/editor_test.dart
Expand Up @@ -2,23 +2,21 @@ part of ice_test;

editor_tests() {
group("defaults", () {
var el;
setUp(() {
var el = new Element.html('<div id=ice-${currentTestCase.id}>');
el = new Element.html('<div>');
document.body.nodes.add(el);
});
tearDown(() {
var el = document.query('#ice-${currentTestCase.id}');
document.body.nodes.remove(el);
});
tearDown(()=> el.remove());

test("defaults to auto-update the preview", () {
var it = new Editor('#ice-${currentTestCase.id}');
var it = new Editor(el);
expect(it.autoupdate, equals(true));
expect(it.editorReady, completes);
});

test("starts an ACE instance", (){
var it = new Editor('#ice-${currentTestCase.id}');
var it = new Editor(el);
it.editorReady.then(
expectAsync((_) {
expect(document.query('.ace_content'), isNotNull);
Expand All @@ -27,25 +25,23 @@ editor_tests() {
});

test("defaults to disable edit-only mode", () {
var it = new Editor('#ice-${currentTestCase.id}');
var it = new Editor(el);
expect(it.edit_only, equals(false));
expect(it.editorReady, completes);
});

});

group("content", () {
var el;
setUp(() {
var el = new Element.html('<div id=ice-${currentTestCase.id}>');
document.body.nodes.add(el);
});
tearDown(() {
var el = document.query('#ice-${currentTestCase.id}');
document.body.nodes.remove(el);
el = new DivElement();
document.body.append(el);
});
tearDown(()=> el.remove());

test("can set the content", () {
var it = new Editor('#ice-${currentTestCase.id}');
var it = new Editor(el);

it.content = 'asdf';

Expand All @@ -59,15 +55,13 @@ editor_tests() {
});

group("focus", (){
var editor;
var el, editor;

setUp((){
document.body.nodes.
add(new Element.html('<div id=ice-${currentTestCase.id}>'));
el = new DivElement();
document.body.append(el);

editor = new Editor('#ice-${currentTestCase.id}');

editor.content = '<h1>preview</h1>';
editor = new Editor(el)..content = '<h1>preview</h1>';

var preview_ready = new Completer();
editor.onPreviewChange.listen((e){
Expand All @@ -77,34 +71,28 @@ editor_tests() {
return preview_ready.future;
});

tearDown(()=> document.body.nodes.
remove(document.query('#ice-${currentTestCase.id}')));
tearDown(()=> el.remove());

test('code is visibile by default', (){
var el = document.
query('#ice-${currentTestCase.id}').
query('.ice-code-editor-editor');
var _el = el.query('.ice-code-editor-editor');

expect(el.style.visibility, isNot('hidden'));
expect(_el.style.visibility, isNot('hidden'));
});

test('focus goes to code if code is visibile', (){
var el = document.
query('#ice-${currentTestCase.id}').
var _el = el.
query('.ice-code-editor-editor').
query('textarea.ace_text-input');

expect(document.activeElement, el);
expect(document.activeElement, _el);
});

test('focus goes to preview if code is hidden', (){
editor.hideCode();

var el = document.
query('#ice-${currentTestCase.id}').
query('iframe');
var _el = el.query('iframe');

expect(document.activeElement, el);
expect(document.activeElement, _el);
});

group("hide code after an update", (){
Expand All @@ -121,27 +109,24 @@ editor_tests() {
});

test('focus goes to preview if code is hidden', (){
var el = document.
query('#ice-${currentTestCase.id}').
query('iframe');
var _el = el.query('iframe');

expect(document.activeElement, el);
expect(document.activeElement, _el);
});
});
// focus goes to preview if code is hidden
// focus goes to preview after update if code is hidden
});

group("line number", (){
var editor;
var el, editor;

setUp((){
document.body.nodes.
add(new Element.html('<div id=ice-${currentTestCase.id}>'));

editor = new Editor('#ice-${currentTestCase.id}');
el = new DivElement();
document.body.append(el);

editor.content = '''
editor = new Editor(el)
..content = '''
Code line 01
Code line 02
Code line 03
Expand All @@ -158,9 +143,7 @@ Code line 07''';
return preview_ready.future;
});

tearDown(()=> document.body.nodes.
remove(document.query('#ice-${currentTestCase.id}')));

tearDown(()=> el.remove());

test("defaults to 1", (){
expect(editor.lineNumber, 1);
Expand Down
48 changes: 24 additions & 24 deletions test/ice_test.dart
Expand Up @@ -32,36 +32,36 @@ part 'full/remove_dialog_test.dart';
part 'full/keyboard_shortcuts_test.dart';
part 'full/snapshotter_test.dart';

main(){
void main(){
Editor.disableJavaScriptWorker = true;

editor_tests();
store_tests();
settings_tests();
gzip_tests();
// store_tests();
// settings_tests();
// gzip_tests();

full_tests();
// full_tests();

update_button_tests();
hide_button_tests();
show_button_tests();
notification_tests();
new_project_dialog_tests();
open_dialog_tests();
copy_dialog_tests();
rename_dialog_tests();
save_dialog_tests();
share_dialog_tests();
download_tests();
export_tests();
import_tests();
whats_new_tests();
remove_dialog_tests();
snapshotter_tests();
// update_button_tests();
// hide_button_tests();
// show_button_tests();
// notification_tests();
// new_project_dialog_tests();
// open_dialog_tests();
// copy_dialog_tests();
// rename_dialog_tests();
// save_dialog_tests();
// share_dialog_tests();
// download_tests();
// export_tests();
// import_tests();
// whats_new_tests();
// remove_dialog_tests();
// snapshotter_tests();

// Leave these tests last b/c they were failing at one point, but only when
// last (hoping to see this again).
keyboard_shortcuts_tests();
// // Leave these tests last b/c they were failing at one point, but only when
// // last (hoping to see this again).
// keyboard_shortcuts_tests();
}

get currentTestCase => new CurrentTestCase();
Expand Down
1 change: 0 additions & 1 deletion test/index.html
@@ -1,2 +1 @@
<script type="application/dart" src="ice_test.dart"></script>
<script src="packages/unittest/test_controller.js"></script>
17 changes: 7 additions & 10 deletions test/test_runner.sh
Expand Up @@ -17,7 +17,7 @@ fi
echo "Looks good!"
echo

which content_shell
which content_shell >/dev/null
if [[ $? -ne 0 ]]; then
$DART_SDK/../chromium/download_contentshell.sh
unzip content_shell-linux-x64-release.zip
Expand All @@ -27,25 +27,22 @@ if [[ $? -ne 0 ]]; then
fi

# Run different test contexts
for X in html5 index
for X in ice_test
do
# Run a set of Dart Unit tests
results=$(content_shell --dump-render-tree test/$X.html)
echo -e "$results"
results=$(pub run test -p 'content-shell' -r expanded test/$X.dart)

# check to see if DumpRenderTree tests
# fails, since it always returns 0
if [[ "$results" == *"Some tests failed"* ]]
if [[ $? -ne 0 ]]
then
echo -e "$results"
exit 1
fi

if [[ "$results" == *"Exception: "* ]]
then
exit 1
fi
echo -e "$results"

if [[ "$results" != *"tests passed."* ]]
if [[ "$results" != *"tests passed"* ]]
then
exit 1
fi
Expand Down

0 comments on commit 327c509

Please sign in to comment.