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

Side by Side Diff: runtime/observatory/lib/src/elements/vm_connect.dart

Issue 2972133002: Restored vm-connect Observatory_UI tests (Closed)
Patch Set: Created 3 years, 5 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
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 library vm_connect_element; 5 library vm_connect_element;
6 6
7 import 'dart:html'; 7 import 'dart:html';
8 import 'dart:async'; 8 import 'dart:async';
9 import 'dart:convert'; 9 import 'dart:convert';
10 import 'package:observatory/models.dart' as M; 10 import 'package:observatory/models.dart' as M;
11 import 'package:observatory/app.dart';
12 import 'package:observatory/src/elements/helpers/tag.dart'; 11 import 'package:observatory/src/elements/helpers/tag.dart';
13 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart'; 12 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart';
14 import 'package:observatory/src/elements/helpers/nav_bar.dart'; 13 import 'package:observatory/src/elements/helpers/nav_bar.dart';
15 import 'package:observatory/src/elements/helpers/uris.dart';
16 import 'package:observatory/src/elements/nav/notify.dart'; 14 import 'package:observatory/src/elements/nav/notify.dart';
17 import 'package:observatory/src/elements/nav/top_menu.dart'; 15 import 'package:observatory/src/elements/nav/top_menu.dart';
18 import 'package:observatory/src/elements/view_footer.dart'; 16 import 'package:observatory/src/elements/view_footer.dart';
19 import 'package:observatory/src/elements/vm_connect_target.dart'; 17 import 'package:observatory/src/elements/vm_connect_target.dart';
20 18
21 typedef void CrashDumpLoadCallback(Map dump); 19 typedef void CrashDumpLoadCallback(Map dump);
22 20
23 class VMConnectElement extends HtmlElement implements Renderable { 21 class VMConnectElement extends HtmlElement implements Renderable {
24 static const tag = 22 static const tag =
25 const Tag<VMConnectElement>('vm-connect', dependencies: const [ 23 const Tag<VMConnectElement>('vm-connect', dependencies: const [
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 new DivElement() 88 new DivElement()
91 ..classes = ['flex-row'] 89 ..classes = ['flex-row']
92 ..children = [ 90 ..children = [
93 new DivElement() 91 new DivElement()
94 ..classes = ['flex-item-40-percent'] 92 ..classes = ['flex-item-40-percent']
95 ..children = [ 93 ..children = [
96 new HeadingElement.h2()..text = 'Connect over WebSocket', 94 new HeadingElement.h2()..text = 'Connect over WebSocket',
97 new BRElement(), 95 new BRElement(),
98 new UListElement() 96 new UListElement()
99 ..children = _targets.list().map((target) { 97 ..children = _targets.list().map((target) {
100 final ObservatoryApplication app = 98 final bool current = _targets.isConnectedVMTarget(target);
101 ObservatoryApplication.app;
102 final bool current = (app != null)
103 ? app.isConnectedVMTarget(target)
104 : false;
105 return new LIElement() 99 return new LIElement()
106 ..children = [ 100 ..children = [
107 new VMConnectTargetElement(target, 101 new VMConnectTargetElement(target,
108 current: current, queue: _r.queue) 102 current: current, queue: _r.queue)
109 ..onConnect.listen(_connect) 103 ..onConnect.listen(_connect)
110 ..onDelete.listen(_delete) 104 ..onDelete.listen(_delete)
111 ]; 105 ];
112 }).toList(), 106 }).toList(),
113 new HRElement(), 107 new HRElement(),
114 new FormElement() 108 new FormElement()
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 return e; 172 return e;
179 } 173 }
180 174
181 void _createAndConnect() { 175 void _createAndConnect() {
182 if (_address == null || _address.isEmpty) return; 176 if (_address == null || _address.isEmpty) return;
183 String normalizedNetworkAddress = _normalizeStandaloneAddress(_address); 177 String normalizedNetworkAddress = _normalizeStandaloneAddress(_address);
184 _targets.add(normalizedNetworkAddress); 178 _targets.add(normalizedNetworkAddress);
185 var target = _targets.find(normalizedNetworkAddress); 179 var target = _targets.find(normalizedNetworkAddress);
186 assert(target != null); 180 assert(target != null);
187 _targets.setCurrent(target); 181 _targets.setCurrent(target);
188 ObservatoryApplication.app.locationManager.go(Uris.vm()); 182 // the navigation to the VM page is done in the ObservatoryApplication
189 } 183 }
190 184
191 void _connect(TargetEvent e) { 185 void _connect(TargetEvent e) {
192 _targets.setCurrent(e.target); 186 _targets.setCurrent(e.target);
193 } 187 }
194 188
195 void _delete(TargetEvent e) => _targets.delete(e.target); 189 void _delete(TargetEvent e) => _targets.delete(e.target);
196 190
197 static String _normalizeStandaloneAddress(String networkAddress) { 191 static String _normalizeStandaloneAddress(String networkAddress) {
198 if (!networkAddress.startsWith('http') && 192 if (!networkAddress.startsWith('http') &&
199 !networkAddress.startsWith('ws')) { 193 !networkAddress.startsWith('ws')) {
200 networkAddress = 'http://$networkAddress'; 194 networkAddress = 'http://$networkAddress';
201 } 195 }
202 try { 196 try {
203 Uri uri = Uri.parse(networkAddress); 197 Uri uri = Uri.parse(networkAddress);
204 return 'ws://${uri.authority}${uri.path}ws'; 198 if (uri.path.endsWith('/ws')) {
199 return 'ws://${uri.authority}${uri.path}';
200 }
201 return 'ws://${uri.authority}${uri.path}/ws';
205 } catch (e) { 202 } catch (e) {
206 print('caught exception with: $networkAddress -- $e'); 203 print('caught exception with: $networkAddress -- $e');
207 return networkAddress; 204 return networkAddress;
208 } 205 }
209 } 206 }
210 } 207 }
OLDNEW
« no previous file with comments | « runtime/observatory/lib/src/elements/css/shared.css ('k') | runtime/observatory/lib/src/elements/vm_connect_target.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698