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

Unified Diff: ui/views/view_model_unittest.cc

Issue 10267023: Gets tab dragging to work in touch mode. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleanup Created 8 years, 8 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
« no previous file with comments | « ui/views/view_model.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/view_model_unittest.cc
diff --git a/ui/views/view_model_unittest.cc b/ui/views/view_model_unittest.cc
index 39e745f92536fda364de6711c7be4f7cb4a00ea0..640e74ebc1645619185851004134d8b8c8a5a98b 100644
--- a/ui/views/view_model_unittest.cc
+++ b/ui/views/view_model_unittest.cc
@@ -4,11 +4,38 @@
#include "ui/views/view_model.h"
+#include "base/string_number_conversions.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/views/view.h"
namespace views {
+namespace {
+
+// Returns a string containing the x-coordinate of each of the views in |model|.
+std::string BoundsString(const ViewModel& model) {
+ std::string result;
+ for (int i = 0; i < model.view_size(); ++i) {
+ if (i != 0)
+ result += " ";
+ result += base::IntToString(model.ideal_bounds(i).x());
+ }
+ return result;
+}
+
+// Returns a string containing the id of each of the views in |model|.
+std::string ViewIDsString(const ViewModel& model) {
+ std::string result;
+ for (int i = 0; i < model.view_size(); ++i) {
+ if (i != 0)
+ result += " ";
+ result += base::IntToString(model.view_at(i)->id());
+ }
+ return result;
+}
+
+} // namespace
+
TEST(ViewModel, BasicAssertions) {
View v1;
ViewModel model;
@@ -23,19 +50,47 @@ TEST(ViewModel, BasicAssertions) {
TEST(ViewModel, Move) {
View v1, v2, v3;
+ v1.set_id(0);
+ v2.set_id(1);
+ v3.set_id(2);
ViewModel model;
model.Add(&v1, 0);
model.Add(&v2, 1);
model.Add(&v3, 2);
model.Move(0, 2);
- EXPECT_EQ(&v1, model.view_at(2));
- EXPECT_EQ(&v2, model.view_at(0));
- EXPECT_EQ(&v3, model.view_at(1));
+ EXPECT_EQ("1 2 0", ViewIDsString(model));
model.Move(2, 0);
- EXPECT_EQ(&v1, model.view_at(0));
- EXPECT_EQ(&v2, model.view_at(1));
- EXPECT_EQ(&v3, model.view_at(2));
+ EXPECT_EQ("0 1 2", ViewIDsString(model));
+}
+
+TEST(ViewModel, MoveViewOnly) {
+ View v1, v2, v3;
+ v1.set_id(0);
+ v2.set_id(1);
+ v3.set_id(2);
+ ViewModel model;
+ model.Add(&v1, 0);
+ model.Add(&v2, 1);
+ model.Add(&v3, 2);
+ model.set_ideal_bounds(0, gfx::Rect(10, 0, 1, 2));
+ model.set_ideal_bounds(1, gfx::Rect(11, 0, 1, 2));
+ model.set_ideal_bounds(2, gfx::Rect(12, 0, 1, 2));
+ model.MoveViewOnly(0, 2);
+ EXPECT_EQ("1 2 0", ViewIDsString(model));
+ EXPECT_EQ("10 11 12", BoundsString(model));
+
+ model.MoveViewOnly(2, 0);
+ EXPECT_EQ("0 1 2", ViewIDsString(model));
+ EXPECT_EQ("10 11 12", BoundsString(model));
+
+ model.MoveViewOnly(0, 1);
+ EXPECT_EQ("1 0 2", ViewIDsString(model));
+ EXPECT_EQ("10 11 12", BoundsString(model));
+
+ model.MoveViewOnly(1, 0);
+ EXPECT_EQ("0 1 2", ViewIDsString(model));
+ EXPECT_EQ("10 11 12", BoundsString(model));
}
} // namespace views
« no previous file with comments | « ui/views/view_model.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698