Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <algorithm> | 5 #include <algorithm> |
| 6 #include <string> | 6 #include <string> |
| 7 | 7 |
| 8 #include "base/string_number_conversions.h" | 8 #include "base/string_number_conversions.h" |
| 9 #include "chrome/browser/tabs/tab_strip_selection_model.h" | 9 #include "chrome/browser/tabs/tab_strip_selection_model.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 33 EXPECT_TRUE(model.empty()); | 33 EXPECT_TRUE(model.empty()); |
| 34 } | 34 } |
| 35 | 35 |
| 36 TEST_F(TabStripSelectionModelTest, SetSelectedIndex) { | 36 TEST_F(TabStripSelectionModelTest, SetSelectedIndex) { |
| 37 TabStripSelectionModel model; | 37 TabStripSelectionModel model; |
| 38 model.SetSelectedIndex(2); | 38 model.SetSelectedIndex(2); |
| 39 EXPECT_EQ("active=2 anchor=2 selection=2", StateAsString(model)); | 39 EXPECT_EQ("active=2 anchor=2 selection=2", StateAsString(model)); |
| 40 EXPECT_FALSE(model.empty()); | 40 EXPECT_FALSE(model.empty()); |
| 41 } | 41 } |
| 42 | 42 |
| 43 TEST_F(TabStripSelectionModelTest, SetSelectedIndexToEmpty) { | |
|
dpapad
2011/06/08 21:19:34
Is this ok, or should it be moved within the previ
sky
2011/06/08 21:59:23
Standalone test is fine by me.
| |
| 44 TabStripSelectionModel model; | |
| 45 model.SetSelectedIndex(-1); | |
| 46 EXPECT_EQ("active=-1 anchor=-1 selection=", StateAsString(model)); | |
| 47 EXPECT_TRUE(model.empty()); | |
| 48 } | |
| 49 | |
| 43 TEST_F(TabStripSelectionModelTest, IncrementFrom) { | 50 TEST_F(TabStripSelectionModelTest, IncrementFrom) { |
| 44 TabStripSelectionModel model; | 51 TabStripSelectionModel model; |
| 45 model.SetSelectedIndex(1); | 52 model.SetSelectedIndex(1); |
| 46 model.IncrementFrom(1); | 53 model.IncrementFrom(1); |
| 47 EXPECT_EQ("active=2 anchor=2 selection=2", StateAsString(model)); | 54 EXPECT_EQ("active=2 anchor=2 selection=2", StateAsString(model)); |
| 48 | 55 |
| 49 // Increment from 4. This shouldn't effect the selection as its past the | 56 // Increment from 4. This shouldn't effect the selection as its past the |
| 50 // end of the selection. | 57 // end of the selection. |
| 51 model.IncrementFrom(4); | 58 model.IncrementFrom(4); |
| 52 EXPECT_EQ("active=2 anchor=2 selection=2", StateAsString(model)); | 59 EXPECT_EQ("active=2 anchor=2 selection=2", StateAsString(model)); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 92 model.AddIndexToSelection(4); | 99 model.AddIndexToSelection(4); |
| 93 EXPECT_EQ("active=2 anchor=2 selection=2 4", StateAsString(model)); | 100 EXPECT_EQ("active=2 anchor=2 selection=2 4", StateAsString(model)); |
| 94 | 101 |
| 95 model.RemoveIndexFromSelection(4); | 102 model.RemoveIndexFromSelection(4); |
| 96 EXPECT_EQ("active=2 anchor=2 selection=2", StateAsString(model)); | 103 EXPECT_EQ("active=2 anchor=2 selection=2", StateAsString(model)); |
| 97 | 104 |
| 98 model.RemoveIndexFromSelection(2); | 105 model.RemoveIndexFromSelection(2); |
| 99 EXPECT_EQ("active=2 anchor=2 selection=", StateAsString(model)); | 106 EXPECT_EQ("active=2 anchor=2 selection=", StateAsString(model)); |
| 100 } | 107 } |
| 101 | 108 |
| 109 TEST_F(TabStripSelectionModelTest, SetSelectionFromAnchorTo) { | |
| 110 TabStripSelectionModel model; | |
| 111 model.SetSelectedIndex(2); | |
| 112 model.SetSelectionFromAnchorTo(7); | |
| 113 EXPECT_EQ("active=7 anchor=2 selection=2 3 4 5 6 7", StateAsString(model)); | |
| 114 | |
| 115 model.Clear(); | |
| 116 model.SetSelectedIndex(7); | |
| 117 model.SetSelectionFromAnchorTo(2); | |
| 118 EXPECT_EQ("active=2 anchor=7 selection=2 3 4 5 6 7", StateAsString(model)); | |
| 119 | |
| 120 model.Clear(); | |
| 121 model.SetSelectionFromAnchorTo(7); | |
| 122 EXPECT_EQ("active=7 anchor=7 selection=7", StateAsString(model)); | |
| 123 } | |
| 124 | |
| 102 TEST_F(TabStripSelectionModelTest, Clear) { | 125 TEST_F(TabStripSelectionModelTest, Clear) { |
| 103 TabStripSelectionModel model; | 126 TabStripSelectionModel model; |
| 104 model.SetSelectedIndex(2); | 127 model.SetSelectedIndex(2); |
| 105 | 128 |
| 106 model.Clear(); | 129 model.Clear(); |
| 107 EXPECT_EQ("active=-1 anchor=-1 selection=", StateAsString(model)); | 130 EXPECT_EQ("active=-1 anchor=-1 selection=", StateAsString(model)); |
| 108 } | 131 } |
| 109 | 132 |
| 110 TEST_F(TabStripSelectionModelTest, MoveToLeft) { | 133 TEST_F(TabStripSelectionModelTest, MoveToLeft) { |
| 111 TabStripSelectionModel model; | 134 TabStripSelectionModel model; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 143 TEST_F(TabStripSelectionModelTest, AddSelectionFromAnchorTo) { | 166 TEST_F(TabStripSelectionModelTest, AddSelectionFromAnchorTo) { |
| 144 TabStripSelectionModel model; | 167 TabStripSelectionModel model; |
| 145 model.SetSelectedIndex(2); | 168 model.SetSelectedIndex(2); |
| 146 | 169 |
| 147 model.AddSelectionFromAnchorTo(4); | 170 model.AddSelectionFromAnchorTo(4); |
| 148 EXPECT_EQ("active=4 anchor=2 selection=2 3 4", StateAsString(model)); | 171 EXPECT_EQ("active=4 anchor=2 selection=2 3 4", StateAsString(model)); |
| 149 | 172 |
| 150 model.AddSelectionFromAnchorTo(0); | 173 model.AddSelectionFromAnchorTo(0); |
| 151 EXPECT_EQ("active=0 anchor=2 selection=0 1 2 3 4", StateAsString(model)); | 174 EXPECT_EQ("active=0 anchor=2 selection=0 1 2 3 4", StateAsString(model)); |
| 152 } | 175 } |
| OLD | NEW |