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

Unified Diff: packages/charted/test.disabled/layout/pie_layout_test.dart

Issue 1400473008: Roll Observatory packages and add a roll script (Closed) Base URL: git@github.com:dart-lang/observatory_pub_packages.git@master
Patch Set: Created 5 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: packages/charted/test.disabled/layout/pie_layout_test.dart
diff --git a/packages/charted/test.disabled/layout/pie_layout_test.dart b/packages/charted/test.disabled/layout/pie_layout_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..12fd13729832413628702f4ed39808b20c6befa1
--- /dev/null
+++ b/packages/charted/test.disabled/layout/pie_layout_test.dart
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2014 Google Inc. All rights reserved.
+ *
+ * Use of this source code is governed by a BSD-style
+ * license that can be found in the LICENSE file or at
+ * https://developers.google.com/open-source/licenses/bsd
+ */
+
+part of charted.test.layout;
+
+testPieLayout() {
+ List mockPieData = [
+ [5, 5, 10],
+ [0, 0],
+ [4],
+ [10, 5, 5], // Case for sorting, results the same as the first case.
+ ];
+ List mockPieAngle = [
+ [[0, PI / 2], [PI / 2, PI], [PI, PI * 2]],
+ [[0, 0], [0, 0]],
+ [[0, 2 * PI]],
+ [[0, PI / 2], [PI / 2, PI], [PI, PI * 2]],
+ ];
+
+ group('PieLayout.startAngleCallback', () {
+ PieLayout pieLayout = new PieLayout();
+ test('= 0 by default', () {
+ expect(pieLayout.startAngleCallback(null, 0, null), equals(0));
+ });
+ PieLayout pieLayout2 = new PieLayout();
+ pieLayout2.startAngle = 0.4;
+ test('equals the manually set value after set by startAngle setter', () {
+ expect(pieLayout2.startAngleCallback(null, 0, null), equals(0.4));
+ });
+ });
+
+ group('PieLayout.endAngleCallback', () {
+ PieLayout pieLayout = new PieLayout();
+ test('= 2 * PI by default', () {
+ expect(pieLayout.endAngleCallback(null, 0, null), equals(2 * PI));
+ });
+ PieLayout pieLayout2 = new PieLayout();
+ pieLayout2.endAngle = 0.4;
+ test('equals the manually set value after set by endAngle setter', () {
+ expect(pieLayout2.endAngleCallback(null, 0, null), equals(0.4));
+ });
+ });
+
+ group('PieLayout.layout', () {
+ test('generates a list of SvgArcData object for pie-chart', () {
+ PieLayout pieLayout = new PieLayout();
+ List slice = pieLayout.layout(mockPieData[0]);
+ for (var i = 0; i < 3; ++i) {
+ expect(slice[i].startAngle, closeTo(mockPieAngle[0][i][0], EPSILON));
+ expect(slice[i].endAngle, closeTo(mockPieAngle[0][i][1], EPSILON));
+ }
+ });
+ test('generates zero-angled slice for total 0 data', () {
+ PieLayout pieLayout = new PieLayout();
+ List slice = pieLayout.layout(mockPieData[1]);
+ for (var i = 0; i < 2; ++i) {
+ expect(slice[i].startAngle, closeTo(mockPieAngle[1][i][0], EPSILON));
+ expect(slice[i].endAngle, closeTo(mockPieAngle[1][i][1], EPSILON));
+ }
+ });
+ test('generates concentric pie sector for solo non-zero data', () {
+ PieLayout pieLayout = new PieLayout();
+ List slice = pieLayout.layout(mockPieData[2]);
+ expect(slice[0].startAngle, closeTo(mockPieAngle[2][0][0], EPSILON));
+ expect(slice[0].endAngle, closeTo(mockPieAngle[2][0][1], EPSILON));
+ });
+ test('supports sorting data', () {
+ PieLayout pieLayout = new PieLayout();
+ pieLayout.compare = (num a, num b) => (a - b).ceil();
+ List slice = pieLayout.layout(mockPieData[3]);
+ for (var i = 0; i < 3; ++i) {
+ expect(slice[i].startAngle, closeTo(mockPieAngle[3][i][0], EPSILON));
+ expect(slice[i].endAngle, closeTo(mockPieAngle[3][i][1], EPSILON));
+ }
+ });
+ });
+}
« no previous file with comments | « packages/charted/test.disabled/layout/layout_test.dart ('k') | packages/charted/test.disabled/locale/locale_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698