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

Side by Side Diff: runtime/observatory/tests/service/get_object_rpc_test.dart

Issue 1790593002: Move the VM's typed_data implementation to runtime/lib. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 9 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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 // VMOptions=--error_on_bad_type --error_on_bad_override 4 // VMOptions=--error_on_bad_type --error_on_bad_override
5 5
6 library get_object_rpc_test; 6 library get_object_rpc_test;
7 7
8 import 'dart:typed_data'; 8 import 'dart:typed_data';
9 import 'dart:convert' show BASE64; 9 import 'dart:convert' show BASE64;
10 import 'package:observatory/service_io.dart'; 10 import 'package:observatory/service_io.dart';
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 var params = { 434 var params = {
435 'objectId': evalResult['id'], 435 'objectId': evalResult['id'],
436 }; 436 };
437 var result = await isolate.invokeRpcNoUpgrade('getObject', params); 437 var result = await isolate.invokeRpcNoUpgrade('getObject', params);
438 expect(result['type'], equals('Instance')); 438 expect(result['type'], equals('Instance'));
439 expect(result['kind'], equals('Uint8List')); 439 expect(result['kind'], equals('Uint8List'));
440 expect(result['_vmType'], equals('TypedData')); 440 expect(result['_vmType'], equals('TypedData'));
441 expect(result['id'], startsWith('objects/')); 441 expect(result['id'], startsWith('objects/'));
442 expect(result['valueAsString'], isNull); 442 expect(result['valueAsString'], isNull);
443 expect(result['class']['type'], equals('@Class')); 443 expect(result['class']['type'], equals('@Class'));
444 expect(result['class']['name'], equals('_Uint8Array')); 444 expect(result['class']['name'], equals('Uint8List'));
445 expect(result['size'], isPositive); 445 expect(result['size'], isPositive);
446 expect(result['fields'], isEmpty); 446 expect(result['fields'], isEmpty);
447 expect(result['length'], equals(3)); 447 expect(result['length'], equals(3));
448 expect(result['offset'], isNull); 448 expect(result['offset'], isNull);
449 expect(result['count'], isNull); 449 expect(result['count'], isNull);
450 expect(result['bytes'], equals('AwIB')); 450 expect(result['bytes'], equals('AwIB'));
451 Uint8List bytes = BASE64.decode(result['bytes']); 451 Uint8List bytes = BASE64.decode(result['bytes']);
452 expect(bytes.buffer.asUint8List().toString(), equals('[3, 2, 1]')); 452 expect(bytes.buffer.asUint8List().toString(), equals('[3, 2, 1]'));
453 }, 453 },
454 454
455 // Uint8List prefix. 455 // Uint8List prefix.
456 (Isolate isolate) async { 456 (Isolate isolate) async {
457 // Call eval to get a Dart list. 457 // Call eval to get a Dart list.
458 var evalResult = await eval(isolate, 'uint8List'); 458 var evalResult = await eval(isolate, 'uint8List');
459 var params = { 459 var params = {
460 'objectId': evalResult['id'], 460 'objectId': evalResult['id'],
461 'count' : 2, 461 'count' : 2,
462 }; 462 };
463 var result = await isolate.invokeRpcNoUpgrade('getObject', params); 463 var result = await isolate.invokeRpcNoUpgrade('getObject', params);
464 expect(result['type'], equals('Instance')); 464 expect(result['type'], equals('Instance'));
465 expect(result['kind'], equals('Uint8List')); 465 expect(result['kind'], equals('Uint8List'));
466 expect(result['_vmType'], equals('TypedData')); 466 expect(result['_vmType'], equals('TypedData'));
467 expect(result['id'], startsWith('objects/')); 467 expect(result['id'], startsWith('objects/'));
468 expect(result['valueAsString'], isNull); 468 expect(result['valueAsString'], isNull);
469 expect(result['class']['type'], equals('@Class')); 469 expect(result['class']['type'], equals('@Class'));
470 expect(result['class']['name'], equals('_Uint8Array')); 470 expect(result['class']['name'], equals('Uint8List'));
471 expect(result['size'], isPositive); 471 expect(result['size'], isPositive);
472 expect(result['fields'], isEmpty); 472 expect(result['fields'], isEmpty);
473 expect(result['length'], equals(3)); 473 expect(result['length'], equals(3));
474 expect(result['offset'], isNull); 474 expect(result['offset'], isNull);
475 expect(result['count'], equals(2)); 475 expect(result['count'], equals(2));
476 expect(result['bytes'], equals('AwI=')); 476 expect(result['bytes'], equals('AwI='));
477 Uint8List bytes = BASE64.decode(result['bytes']); 477 Uint8List bytes = BASE64.decode(result['bytes']);
478 expect(bytes.buffer.asUint8List().toString(), equals('[3, 2]')); 478 expect(bytes.buffer.asUint8List().toString(), equals('[3, 2]'));
479 }, 479 },
480 480
481 // Uint8List suffix. 481 // Uint8List suffix.
482 (Isolate isolate) async { 482 (Isolate isolate) async {
483 // Call eval to get a Dart list. 483 // Call eval to get a Dart list.
484 var evalResult = await eval(isolate, 'uint8List'); 484 var evalResult = await eval(isolate, 'uint8List');
485 var params = { 485 var params = {
486 'objectId': evalResult['id'], 486 'objectId': evalResult['id'],
487 'offset' : 2, 487 'offset' : 2,
488 'count' : 2, 488 'count' : 2,
489 }; 489 };
490 var result = await isolate.invokeRpcNoUpgrade('getObject', params); 490 var result = await isolate.invokeRpcNoUpgrade('getObject', params);
491 expect(result['type'], equals('Instance')); 491 expect(result['type'], equals('Instance'));
492 expect(result['kind'], equals('Uint8List')); 492 expect(result['kind'], equals('Uint8List'));
493 expect(result['_vmType'], equals('TypedData')); 493 expect(result['_vmType'], equals('TypedData'));
494 expect(result['id'], startsWith('objects/')); 494 expect(result['id'], startsWith('objects/'));
495 expect(result['valueAsString'], isNull); 495 expect(result['valueAsString'], isNull);
496 expect(result['class']['type'], equals('@Class')); 496 expect(result['class']['type'], equals('@Class'));
497 expect(result['class']['name'], equals('_Uint8Array')); 497 expect(result['class']['name'], equals('Uint8List'));
498 expect(result['size'], isPositive); 498 expect(result['size'], isPositive);
499 expect(result['fields'], isEmpty); 499 expect(result['fields'], isEmpty);
500 expect(result['length'], equals(3)); 500 expect(result['length'], equals(3));
501 expect(result['offset'], equals(2)); 501 expect(result['offset'], equals(2));
502 expect(result['count'], equals(1)); 502 expect(result['count'], equals(1));
503 expect(result['bytes'], equals('AQ==')); 503 expect(result['bytes'], equals('AQ=='));
504 Uint8List bytes = BASE64.decode(result['bytes']); 504 Uint8List bytes = BASE64.decode(result['bytes']);
505 expect(bytes.buffer.asUint8List().toString(), equals('[1]')); 505 expect(bytes.buffer.asUint8List().toString(), equals('[1]'));
506 }, 506 },
507 507
508 // Uint8List with wacky offset. 508 // Uint8List with wacky offset.
509 (Isolate isolate) async { 509 (Isolate isolate) async {
510 // Call eval to get a Dart list. 510 // Call eval to get a Dart list.
511 var evalResult = await eval(isolate, 'uint8List'); 511 var evalResult = await eval(isolate, 'uint8List');
512 var params = { 512 var params = {
513 'objectId': evalResult['id'], 513 'objectId': evalResult['id'],
514 'offset' : 100, 514 'offset' : 100,
515 'count' : 2, 515 'count' : 2,
516 }; 516 };
517 var result = await isolate.invokeRpcNoUpgrade('getObject', params); 517 var result = await isolate.invokeRpcNoUpgrade('getObject', params);
518 expect(result['type'], equals('Instance')); 518 expect(result['type'], equals('Instance'));
519 expect(result['kind'], equals('Uint8List')); 519 expect(result['kind'], equals('Uint8List'));
520 expect(result['_vmType'], equals('TypedData')); 520 expect(result['_vmType'], equals('TypedData'));
521 expect(result['id'], startsWith('objects/')); 521 expect(result['id'], startsWith('objects/'));
522 expect(result['valueAsString'], isNull); 522 expect(result['valueAsString'], isNull);
523 expect(result['class']['type'], equals('@Class')); 523 expect(result['class']['type'], equals('@Class'));
524 expect(result['class']['name'], equals('_Uint8Array')); 524 expect(result['class']['name'], equals('Uint8List'));
525 expect(result['size'], isPositive); 525 expect(result['size'], isPositive);
526 expect(result['fields'], isEmpty); 526 expect(result['fields'], isEmpty);
527 expect(result['length'], equals(3)); 527 expect(result['length'], equals(3));
528 expect(result['offset'], equals(3)); 528 expect(result['offset'], equals(3));
529 expect(result['count'], equals(0)); 529 expect(result['count'], equals(0));
530 expect(result['bytes'], equals('')); 530 expect(result['bytes'], equals(''));
531 }, 531 },
532 532
533 // Uint64List. 533 // Uint64List.
534 (Isolate isolate) async { 534 (Isolate isolate) async {
535 // Call eval to get a Dart list. 535 // Call eval to get a Dart list.
536 var evalResult = await eval(isolate, 'uint64List'); 536 var evalResult = await eval(isolate, 'uint64List');
537 var params = { 537 var params = {
538 'objectId': evalResult['id'], 538 'objectId': evalResult['id'],
539 }; 539 };
540 var result = await isolate.invokeRpcNoUpgrade('getObject', params); 540 var result = await isolate.invokeRpcNoUpgrade('getObject', params);
541 expect(result['type'], equals('Instance')); 541 expect(result['type'], equals('Instance'));
542 expect(result['kind'], equals('Uint64List')); 542 expect(result['kind'], equals('Uint64List'));
543 expect(result['_vmType'], equals('TypedData')); 543 expect(result['_vmType'], equals('TypedData'));
544 expect(result['id'], startsWith('objects/')); 544 expect(result['id'], startsWith('objects/'));
545 expect(result['valueAsString'], isNull); 545 expect(result['valueAsString'], isNull);
546 expect(result['class']['type'], equals('@Class')); 546 expect(result['class']['type'], equals('@Class'));
547 expect(result['class']['name'], equals('_Uint64Array')); 547 expect(result['class']['name'], equals('Uint64List'));
548 expect(result['size'], isPositive); 548 expect(result['size'], isPositive);
549 expect(result['fields'], isEmpty); 549 expect(result['fields'], isEmpty);
550 expect(result['length'], equals(3)); 550 expect(result['length'], equals(3));
551 expect(result['offset'], isNull); 551 expect(result['offset'], isNull);
552 expect(result['count'], isNull); 552 expect(result['count'], isNull);
553 expect(result['bytes'], equals('AwAAAAAAAAACAAAAAAAAAAEAAAAAAAAA')); 553 expect(result['bytes'], equals('AwAAAAAAAAACAAAAAAAAAAEAAAAAAAAA'));
554 Uint8List bytes = BASE64.decode(result['bytes']); 554 Uint8List bytes = BASE64.decode(result['bytes']);
555 expect(bytes.buffer.asUint64List().toString(), equals('[3, 2, 1]')); 555 expect(bytes.buffer.asUint64List().toString(), equals('[3, 2, 1]'));
556 }, 556 },
557 557
558 // Uint64List prefix. 558 // Uint64List prefix.
559 (Isolate isolate) async { 559 (Isolate isolate) async {
560 // Call eval to get a Dart list. 560 // Call eval to get a Dart list.
561 var evalResult = await eval(isolate, 'uint64List'); 561 var evalResult = await eval(isolate, 'uint64List');
562 var params = { 562 var params = {
563 'objectId': evalResult['id'], 563 'objectId': evalResult['id'],
564 'count' : 2, 564 'count' : 2,
565 }; 565 };
566 var result = await isolate.invokeRpcNoUpgrade('getObject', params); 566 var result = await isolate.invokeRpcNoUpgrade('getObject', params);
567 expect(result['type'], equals('Instance')); 567 expect(result['type'], equals('Instance'));
568 expect(result['kind'], equals('Uint64List')); 568 expect(result['kind'], equals('Uint64List'));
569 expect(result['_vmType'], equals('TypedData')); 569 expect(result['_vmType'], equals('TypedData'));
570 expect(result['id'], startsWith('objects/')); 570 expect(result['id'], startsWith('objects/'));
571 expect(result['valueAsString'], isNull); 571 expect(result['valueAsString'], isNull);
572 expect(result['class']['type'], equals('@Class')); 572 expect(result['class']['type'], equals('@Class'));
573 expect(result['class']['name'], equals('_Uint64Array')); 573 expect(result['class']['name'], equals('Uint64List'));
574 expect(result['size'], isPositive); 574 expect(result['size'], isPositive);
575 expect(result['fields'], isEmpty); 575 expect(result['fields'], isEmpty);
576 expect(result['length'], equals(3)); 576 expect(result['length'], equals(3));
577 expect(result['offset'], isNull); 577 expect(result['offset'], isNull);
578 expect(result['count'], equals(2)); 578 expect(result['count'], equals(2));
579 expect(result['bytes'], equals('AwAAAAAAAAACAAAAAAAAAA==')); 579 expect(result['bytes'], equals('AwAAAAAAAAACAAAAAAAAAA=='));
580 Uint8List bytes = BASE64.decode(result['bytes']); 580 Uint8List bytes = BASE64.decode(result['bytes']);
581 expect(bytes.buffer.asUint64List().toString(), equals('[3, 2]')); 581 expect(bytes.buffer.asUint64List().toString(), equals('[3, 2]'));
582 }, 582 },
583 583
584 // Uint64List suffix. 584 // Uint64List suffix.
585 (Isolate isolate) async { 585 (Isolate isolate) async {
586 // Call eval to get a Dart list. 586 // Call eval to get a Dart list.
587 var evalResult = await eval(isolate, 'uint64List'); 587 var evalResult = await eval(isolate, 'uint64List');
588 var params = { 588 var params = {
589 'objectId': evalResult['id'], 589 'objectId': evalResult['id'],
590 'offset' : 2, 590 'offset' : 2,
591 'count' : 2, 591 'count' : 2,
592 }; 592 };
593 var result = await isolate.invokeRpcNoUpgrade('getObject', params); 593 var result = await isolate.invokeRpcNoUpgrade('getObject', params);
594 expect(result['type'], equals('Instance')); 594 expect(result['type'], equals('Instance'));
595 expect(result['kind'], equals('Uint64List')); 595 expect(result['kind'], equals('Uint64List'));
596 expect(result['_vmType'], equals('TypedData')); 596 expect(result['_vmType'], equals('TypedData'));
597 expect(result['id'], startsWith('objects/')); 597 expect(result['id'], startsWith('objects/'));
598 expect(result['valueAsString'], isNull); 598 expect(result['valueAsString'], isNull);
599 expect(result['class']['type'], equals('@Class')); 599 expect(result['class']['type'], equals('@Class'));
600 expect(result['class']['name'], equals('_Uint64Array')); 600 expect(result['class']['name'], equals('Uint64List'));
601 expect(result['size'], isPositive); 601 expect(result['size'], isPositive);
602 expect(result['fields'], isEmpty); 602 expect(result['fields'], isEmpty);
603 expect(result['length'], equals(3)); 603 expect(result['length'], equals(3));
604 expect(result['offset'], equals(2)); 604 expect(result['offset'], equals(2));
605 expect(result['count'], equals(1)); 605 expect(result['count'], equals(1));
606 expect(result['bytes'], equals('AQAAAAAAAAA=')); 606 expect(result['bytes'], equals('AQAAAAAAAAA='));
607 Uint8List bytes = BASE64.decode(result['bytes']); 607 Uint8List bytes = BASE64.decode(result['bytes']);
608 expect(bytes.buffer.asUint64List().toString(), equals('[1]')); 608 expect(bytes.buffer.asUint64List().toString(), equals('[1]'));
609 }, 609 },
610 610
611 // Uint64List with wacky offset. 611 // Uint64List with wacky offset.
612 (Isolate isolate) async { 612 (Isolate isolate) async {
613 // Call eval to get a Dart list. 613 // Call eval to get a Dart list.
614 var evalResult = await eval(isolate, 'uint64List'); 614 var evalResult = await eval(isolate, 'uint64List');
615 var params = { 615 var params = {
616 'objectId': evalResult['id'], 616 'objectId': evalResult['id'],
617 'offset' : 100, 617 'offset' : 100,
618 'count' : 2, 618 'count' : 2,
619 }; 619 };
620 var result = await isolate.invokeRpcNoUpgrade('getObject', params); 620 var result = await isolate.invokeRpcNoUpgrade('getObject', params);
621 expect(result['type'], equals('Instance')); 621 expect(result['type'], equals('Instance'));
622 expect(result['kind'], equals('Uint64List')); 622 expect(result['kind'], equals('Uint64List'));
623 expect(result['_vmType'], equals('TypedData')); 623 expect(result['_vmType'], equals('TypedData'));
624 expect(result['id'], startsWith('objects/')); 624 expect(result['id'], startsWith('objects/'));
625 expect(result['valueAsString'], isNull); 625 expect(result['valueAsString'], isNull);
626 expect(result['class']['type'], equals('@Class')); 626 expect(result['class']['type'], equals('@Class'));
627 expect(result['class']['name'], equals('_Uint64Array')); 627 expect(result['class']['name'], equals('Uint64List'));
628 expect(result['size'], isPositive); 628 expect(result['size'], isPositive);
629 expect(result['fields'], isEmpty); 629 expect(result['fields'], isEmpty);
630 expect(result['length'], equals(3)); 630 expect(result['length'], equals(3));
631 expect(result['offset'], equals(3)); 631 expect(result['offset'], equals(3));
632 expect(result['count'], equals(0)); 632 expect(result['count'], equals(0));
633 expect(result['bytes'], equals('')); 633 expect(result['bytes'], equals(''));
634 }, 634 },
635 635
636 // An expired object. 636 // An expired object.
637 (Isolate isolate) async { 637 (Isolate isolate) async {
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
947 caughtException = true; 947 caughtException = true;
948 expect(e.code, equals(ServerRpcException.kInvalidParams)); 948 expect(e.code, equals(ServerRpcException.kInvalidParams));
949 expect(e.message, 949 expect(e.message,
950 "getObject: invalid 'objectId' parameter: code/0"); 950 "getObject: invalid 'objectId' parameter: code/0");
951 } 951 }
952 expect(caughtException, isTrue); 952 expect(caughtException, isTrue);
953 }, 953 },
954 ]; 954 ];
955 955
956 main(args) async => runIsolateTests(args, tests, testeeBefore:warmup); 956 main(args) async => runIsolateTests(args, tests, testeeBefore:warmup);
OLDNEW
« no previous file with comments | « runtime/lib/typed_data.dart ('k') | runtime/vm/bootstrap.cc » ('j') | runtime/vm/vm.gypi » ('J')

Powered by Google App Engine
This is Rietveld 408576698