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

Side by Side Diff: chrome/browser/ui/tabs/tab_mru_list_manager_unittest.cc

Issue 10117016: Implementation for switching between recently used tabs using ctrl tilde or quoteleft. Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fixed review comments. Created 8 years, 6 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
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 "chrome/browser/ui/tabs/tab_mru_list_manager.h"
sky 2012/06/15 19:47:39 newline between 5 and 6.
6 #include "chrome/browser/ui/tabs/tab_strip_model.h"
7 #include "testing/gtest/include/gtest/gtest.h"
8
9 typedef testing::Test TabMRUListManagerTest;
10
11 // Swich to MRU tab when list is empty.
12 TEST_F(TabMRUListManagerTest, ListEmpty) {
13 TabMRUListManager mru_list(NULL);
14 TabContentsWrapper* contents = mru_list.GetPreviousMRUTab();
15 EXPECT_EQ(NULL, contents);
16 }
17
18 // Insert 3 tabs and switch between first and 3rd tab
19 TEST_F(TabMRUListManagerTest, ToggleMRUTabs) {
20 TabMRUListManager mru_list(NULL);
21 TabContentsWrapper* contents1 = (TabContentsWrapper*) 0xfffffff1;
sky 2012/06/15 19:47:39 Don't do this. You can create TabContents in unit
22 TabContentsWrapper* contents2 = (TabContentsWrapper*) 0xfffffff2;
23 TabContentsWrapper* contents3 = (TabContentsWrapper*) 0xfffffff3;
24
25 mru_list.TabInsertedAt(contents1, 0, true);
26 mru_list.TabInsertedAt(contents2, 1, true);
27 mru_list.TabInsertedAt(contents3, 2, true);
28
29 // content3 will be the current active tab and contents2 will be
30 // the most recently used tab.
31 // Now activate contents1 so that we toggle between contents1 and
32 // contents3
33 mru_list.ActiveTabChanged(contents3, contents1, 0, true);
34
35 // Now calling GetPreviousMRUTab will return contents3 because we
36 // shifted to contents1 from contents3,
37 TabContentsWrapper* contents = mru_list.GetPreviousMRUTab();
38 EXPECT_EQ(contents, contents3);
39 }
40
41 // Detach a MRU tab and check the behaviour
42 // Insert 3 tabs and switch between first and 3rd tab
43 TEST_F(TabMRUListManagerTest, DetachMRUTabs) {
44 TabMRUListManager mru_list(NULL);
45 TabContentsWrapper* contents1 = (TabContentsWrapper*) 0xfffffff1;
46 TabContentsWrapper* contents2 = (TabContentsWrapper*) 0xfffffff2;
47 TabContentsWrapper* contents3 = (TabContentsWrapper*) 0xfffffff3;
48
49 mru_list.TabInsertedAt(contents1, 0, true);
50 mru_list.TabInsertedAt(contents2, 1, true);
51 mru_list.TabInsertedAt(contents3, 2, true);
52
53 // content3 will be the current active tab and contents2 will be
54 // the most recently used tab.
55 // Now activate contents1 so that we toggle between contents1 and
56 // contents3
57 mru_list.ActiveTabChanged(contents3, contents1, 0, true);
58
59 // Now calling GetPreviousMRUTab will return contents3 because we
60 // shifted to contents1 from contents3,
61 TabContentsWrapper* contents = mru_list.GetPreviousMRUTab();
62 EXPECT_EQ(contents, contents3);
63
64 // Detach contents3 and then the next MRU tab should be contents2
65 // as per MRU order.
66 mru_list.TabDetachedAt(contents3, 2);
67 contents = mru_list.GetPreviousMRUTab();
68 EXPECT_EQ(contents, contents2);
69 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698