Chromium Code Reviews
[email protected] (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(71)

Side by Side Diff: chrome/browser/tabs/pinned_tab_codec_unittest.cc

Issue 1026005: Makes pinned tab restore on startup if you haven't enabled session (Closed)
Patch Set: check Created 10 years, 9 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 | « chrome/browser/tabs/pinned_tab_codec.cc ('k') | chrome/browser/tabs/pinned_tab_service.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) 2010 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 <string>
6 #include <vector>
7
8 #include "chrome/browser/tabs/pinned_tab_codec.h"
9 #include "chrome/test/browser_with_test_window_test.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11
12 typedef BrowserInit::LaunchWithProfile::Tab Tab;
13
14 typedef BrowserWithTestWindowTest PinnedTabCodecTest;
15
16 namespace {
17
18 std::string TabToString(const Tab& tab) {
19 return tab.url.spec() + ":" + (tab.is_app ? "app" : "") + ":" +
20 (tab.is_pinned ? "pinned" : "") + ":" + tab.app_id;
21 }
22
23 std::string TabsToString(const std::vector<Tab>& values) {
24 std::string result;
25 for (size_t i = 0; i < values.size(); ++i) {
26 if (i != 0)
27 result += " ";
28 result += TabToString(values[i]);
29 }
30 return result;
31 }
32
33 } // namespace
34
35 // Make sure nothing is restored when the browser has no pinned tabs.
36 TEST_F(PinnedTabCodecTest, NoPinnedTabs) {
37 GURL url1("http://www.google.com");
38 AddTab(browser(), url1);
39
40 PinnedTabCodec::WritePinnedTabs(profile());
41
42 std::string result = TabsToString(PinnedTabCodec::ReadPinnedTabs(profile()));
43 EXPECT_EQ("", result);
44 }
45
46 // Creates a browser with one pinned tab and one normal tab, does restore and
47 // makes sure we get back another pinned tab.
48 TEST_F(PinnedTabCodecTest, PinnedAndNonPinned) {
49 GURL url1("http://www.google.com");
50 GURL url2("http://www.google.com/2");
51 AddTab(browser(), url2);
52
53 // AddTab inserts at index 0, so order after this is url1, url2.
54 AddTab(browser(), url1);
55
56 browser()->tabstrip_model()->SetTabPinned(0, true);
57
58 PinnedTabCodec::WritePinnedTabs(profile());
59
60 std::string result = TabsToString(PinnedTabCodec::ReadPinnedTabs(profile()));
61 EXPECT_EQ("http://www.google.com/::pinned:", result);
62 }
63
OLDNEW
« no previous file with comments | « chrome/browser/tabs/pinned_tab_codec.cc ('k') | chrome/browser/tabs/pinned_tab_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698