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

Side by Side Diff: ui/views/view_model_utils_unittest.cc

Issue 10388036: Adds the option of aligning the launcher to the left or right. There (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix compile Created 8 years, 7 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
« no previous file with comments | « ui/views/view_model_utils.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/views/view_model_utils.h" 5 #include "ui/views/view_model_utils.h"
6 6
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 #include "ui/views/view.h" 8 #include "ui/views/view.h"
9 #include "ui/views/view_model.h" 9 #include "ui/views/view_model.h"
10 10
(...skipping 14 matching lines...) Expand all
25 TEST(ViewModelUtils, DetermineMoveIndex) { 25 TEST(ViewModelUtils, DetermineMoveIndex) {
26 View v1, v2, v3; 26 View v1, v2, v3;
27 ViewModel model; 27 ViewModel model;
28 model.Add(&v1, 0); 28 model.Add(&v1, 0);
29 model.Add(&v2, 1); 29 model.Add(&v2, 1);
30 model.Add(&v3, 2); 30 model.Add(&v3, 2);
31 model.set_ideal_bounds(0, gfx::Rect(0, 0, 10, 10)); 31 model.set_ideal_bounds(0, gfx::Rect(0, 0, 10, 10));
32 model.set_ideal_bounds(1, gfx::Rect(10, 0, 1000, 10)); 32 model.set_ideal_bounds(1, gfx::Rect(10, 0, 1000, 10));
33 model.set_ideal_bounds(2, gfx::Rect(1010, 0, 2, 10)); 33 model.set_ideal_bounds(2, gfx::Rect(1010, 0, 2, 10));
34 34
35 EXPECT_EQ(0, ViewModelUtils::DetermineMoveIndex(model, &v1, -10)); 35 EXPECT_EQ(0, ViewModelUtils::DetermineMoveIndex(
36 EXPECT_EQ(0, ViewModelUtils::DetermineMoveIndex(model, &v1, 4)); 36 model, &v1, ViewModelUtils::HORIZONTAL, -10, 0));
37 EXPECT_EQ(1, ViewModelUtils::DetermineMoveIndex(model, &v1, 506)); 37 EXPECT_EQ(0, ViewModelUtils::DetermineMoveIndex(
38 EXPECT_EQ(2, ViewModelUtils::DetermineMoveIndex(model, &v1, 1010)); 38 model, &v1, ViewModelUtils::HORIZONTAL, 4, 0));
39 EXPECT_EQ(2, ViewModelUtils::DetermineMoveIndex(model, &v1, 2000)); 39 EXPECT_EQ(1, ViewModelUtils::DetermineMoveIndex(
40 model, &v1, ViewModelUtils::HORIZONTAL, 506, 0));
41 EXPECT_EQ(2, ViewModelUtils::DetermineMoveIndex(
42 model, &v1, ViewModelUtils::HORIZONTAL, 1010, 0));
43 EXPECT_EQ(2, ViewModelUtils::DetermineMoveIndex(
44 model, &v1, ViewModelUtils::HORIZONTAL, 2000, 0));
40 45
41 EXPECT_EQ(0, ViewModelUtils::DetermineMoveIndex(model, &v2, -10)); 46 EXPECT_EQ(0, ViewModelUtils::DetermineMoveIndex(
42 EXPECT_EQ(0, ViewModelUtils::DetermineMoveIndex(model, &v2, 4)); 47 model, &v2, ViewModelUtils::HORIZONTAL, -10, 0));
43 EXPECT_EQ(2, ViewModelUtils::DetermineMoveIndex(model, &v2, 12)); 48 EXPECT_EQ(0, ViewModelUtils::DetermineMoveIndex(
49 model, &v2, ViewModelUtils::HORIZONTAL, 4, 0));
50 EXPECT_EQ(2, ViewModelUtils::DetermineMoveIndex(
51 model, &v2, ViewModelUtils::HORIZONTAL, 12, 0));
52
53 // Try the same when vertical.
54 model.set_ideal_bounds(0, gfx::Rect(0, 0, 10, 10));
55 model.set_ideal_bounds(1, gfx::Rect(0, 10, 10, 1000));
56 model.set_ideal_bounds(2, gfx::Rect(0, 1010, 10, 2));
57
58 EXPECT_EQ(0, ViewModelUtils::DetermineMoveIndex(
59 model, &v1, ViewModelUtils::VERTICAL, 0, -10));
60 EXPECT_EQ(0, ViewModelUtils::DetermineMoveIndex(
61 model, &v1, ViewModelUtils::VERTICAL, 0, 4));
62 EXPECT_EQ(1, ViewModelUtils::DetermineMoveIndex(
63 model, &v1, ViewModelUtils::VERTICAL, 0, 506));
64 EXPECT_EQ(2, ViewModelUtils::DetermineMoveIndex(
65 model, &v1, ViewModelUtils::VERTICAL, 0, 1010));
66 EXPECT_EQ(2, ViewModelUtils::DetermineMoveIndex(
67 model, &v1, ViewModelUtils::VERTICAL, 0, 2000));
68
69 EXPECT_EQ(0, ViewModelUtils::DetermineMoveIndex(
70 model, &v2, ViewModelUtils::VERTICAL, 0, -10));
71 EXPECT_EQ(0, ViewModelUtils::DetermineMoveIndex(
72 model, &v2, ViewModelUtils::VERTICAL, 0, 4));
73 EXPECT_EQ(2, ViewModelUtils::DetermineMoveIndex(
74 model, &v2, ViewModelUtils::VERTICAL, 0, 12));
44 } 75 }
45 76
46 } // namespace views 77 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/view_model_utils.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698