Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(100)

Side by Side Diff: pkg/polymer/test/build/log_injector_test.dart

Issue 513023002: Step one towards stable error messages with details: (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import 'dart:async'; 5 import 'dart:async';
6 import 'dart:html'; 6 import 'dart:html';
7 import 'package:unittest/unittest.dart'; 7 import 'package:unittest/unittest.dart';
8 import 'package:unittest/html_config.dart'; 8 import 'package:unittest/html_config.dart';
9 import 'package:polymer/src/build/log_injector.dart'; 9 import 'package:polymer/src/build/log_injector.dart';
10 10
11 11
12 main() { 12 main() {
13 13
14 useHtmlConfiguration(); 14 useHtmlConfiguration();
15 15
16 setUp(() => new LogInjector().injectLogs( 16 setUp(() => new LogInjector().injectLogs(
17 '''[ 17 '''{
18 {"level": "Info", "message": "foo"}, 18 "polymer#0":[{
19 {"level": "Warning", "message": "bar"}, 19 "level":"Info",
20 {"level": "Error", "message": "baz"} 20 "message":{"id":"polymer#0","snippet":"foo"}}
21 ]''' 21 ],
22 "polymer#1":[{
23 "level":"Info",
24 "message":{"id":"polymer#1","snippet":"foo"},
25 "span":{
26 "start":{
27 "url":"web/test.html",
28 "offset":22,
29 "line":1,
30 "column":0
31 },
32 "end":{
33 "url":"web/test.html",
34 "offset":50,
35 "line":1,
36 "column":28
37 },
38 "text":"<polymer-element name=\\"x-a\\">"
39 }
40 }],
41 "polymer#2":[
42 {"level":"Warning","message":{"id":"polymer#2","snippet":"bar"}},
43 {"level":"Warning","message":{"id":"polymer#2",
44 "snippet":"bar again"}},
45 {"level":"Error","message":{"id":"polymer#2","snippet":"baz1"}}
46 ],
47 "foo#44":[{"level":"Error","message":{"id":"foo#44","snippet":"baz2"}}]
48 }'''
22 )); 49 ));
23 50
24 test('can inject a functioning log widget', () { 51 test('can inject a functioning log widget', () {
25 var logsElement = document.querySelector(".build-logs"); 52 var logsElement = document.querySelector(".build-logs");
26 expect(logsElement, isNotNull); 53 expect(logsElement, isNotNull);
27 54
28 var menuElements = logsElement.querySelectorAll(".menu > div"); 55 var menuElements = logsElement.querySelectorAll(".menu > div");
29 expect(menuElements.length, 3); 56 expect(menuElements.length, 3);
30 var contentElements = logsElement.querySelectorAll(".content > div"); 57 var contentElements = logsElement.querySelectorAll(".content > div");
31 expect(contentElements.length, 3); 58 expect(contentElements.length, 3);
32 59
33 var expectedClasses = ['info', 'warning', 'error']; 60 var expectedClasses = ['info', 'warning', 'error'];
34 61
35 // Check initial setup. 62 // Check initial setup.
36 for (var i = 0; i < menuElements.length; ++i) { 63 for (var i = 0; i < menuElements.length; ++i) {
37 expect(menuElements[i].classes.contains(expectedClasses[i]), true); 64 expect(menuElements[i].classes.contains(expectedClasses[i]), true);
38 expect(menuElements[i].classes.contains('active'), false); 65 expect(menuElements[i].classes.contains('active'), false);
39 expect(contentElements[i].classes.contains(expectedClasses[i]), true); 66 expect(contentElements[i].classes.contains(expectedClasses[i]), true);
40 expect(contentElements[i].classes.contains('active'), false); 67 expect(contentElements[i].classes.contains('active'), false);
41 expect(contentElements[i].querySelectorAll('.log').length, 1); 68 expect(contentElements[i].querySelectorAll('.log').length, 2);
42 } 69 }
43 70
44 // Test clicking each of the tabs. 71 // Test clicking each of the tabs.
45 for (var i = 0; i < menuElements.length; ++i) { 72 for (var i = 0; i < menuElements.length; ++i) {
46 menuElements[i].click(); 73 menuElements[i].click();
47 for (var j = 0; j < menuElements.length; ++j) { 74 for (var j = 0; j < menuElements.length; ++j) {
48 expect(menuElements[j].classes.contains('active'), j == i); 75 expect(menuElements[j].classes.contains('active'), j == i);
49 expect(contentElements[j].classes.contains('active'), j == i); 76 expect(contentElements[j].classes.contains('active'), j == i);
50 } 77 }
51 } 78 }
52 79
53 // Test toggling same tab. 80 // Test toggling same tab.
54 expect(menuElements[2].classes.contains('active'), true); 81 expect(menuElements[2].classes.contains('active'), true);
55 menuElements[2].click(); 82 menuElements[2].click();
56 expect(menuElements[2].classes.contains('active'), false); 83 expect(menuElements[2].classes.contains('active'), false);
57 expect(contentElements[2].classes.contains('active'), false); 84 expect(contentElements[2].classes.contains('active'), false);
58 }); 85 });
59 } 86 }
OLDNEW
« no previous file with comments | « pkg/polymer/test/build/linter_test.dart ('k') | pkg/polymer/test/build/script_compactor_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698