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

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

Issue 851853002: It is time. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Trying to reup because the last upload failed. Created 5 years, 11 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
« no previous file with comments | « ui/views/view_model_utils.cc ('k') | ui/views/view_targeter.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "ui/views/view_model_utils.h"
6
7 #include "testing/gtest/include/gtest/gtest.h"
8 #include "ui/views/view.h"
9 #include "ui/views/view_model.h"
10
11 namespace views {
12
13 // Makes sure SetViewBoundsToIdealBounds updates the view appropriately.
14 TEST(ViewModelUtils, SetViewBoundsToIdealBounds) {
15 View v1;
16 ViewModel model;
17 model.Add(&v1, 0);
18 gfx::Rect v1_bounds(1, 2, 3, 4);
19 model.set_ideal_bounds(0, v1_bounds);
20 ViewModelUtils::SetViewBoundsToIdealBounds(model);
21 EXPECT_EQ(v1_bounds, v1.bounds());
22 }
23
24 // Assertions for DetermineMoveIndex.
25 TEST(ViewModelUtils, DetermineMoveIndex) {
26 View v1, v2, v3;
27 ViewModel model;
28 model.Add(&v1, 0);
29 model.Add(&v2, 1);
30 model.Add(&v3, 2);
31 model.set_ideal_bounds(0, gfx::Rect(0, 0, 10, 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));
34
35 EXPECT_EQ(0, ViewModelUtils::DetermineMoveIndex(
36 model, &v1, ViewModelUtils::HORIZONTAL, -10, 0));
37 EXPECT_EQ(0, ViewModelUtils::DetermineMoveIndex(
38 model, &v1, ViewModelUtils::HORIZONTAL, 4, 0));
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));
45
46 EXPECT_EQ(0, ViewModelUtils::DetermineMoveIndex(
47 model, &v2, ViewModelUtils::HORIZONTAL, -10, 0));
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));
75 }
76
77 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/view_model_utils.cc ('k') | ui/views/view_targeter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698