Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "testing/gtest/include/gtest/gtest.h" | |
|
sky
2011/09/20 16:24:46
test files have a similar include layout to that o
noyau (Ping after 24h)
2011/09/20 17:09:35
Done.
| |
| 6 | |
| 7 #include "base/string16.h" | |
| 8 #include "base/utf_string_conversions.h" | |
| 9 #include "chrome/browser/sessions/session_types.h" | |
| 10 #include "chrome/browser/sessions/session_utils.h" | |
| 11 #include "googleurl/src/gurl.h" | |
| 12 | |
| 13 class TabNavigationMock : public TabNavigation { | |
| 14 public: | |
| 15 TabNavigationMock(const GURL& url, const string16& title) | |
| 16 : TabNavigation(0, // index | |
|
sky
2011/09/20 16:24:46
indent this by 4.
noyau (Ping after 24h)
2011/09/20 17:09:35
Done.
| |
| 17 url, // virtual_url | |
| 18 GURL(), // referrer | |
| 19 title, // title | |
| 20 "", // state | |
| 21 PageTransition::FROM_ADDRESS_BAR) { | |
| 22 } | |
| 23 }; | |
| 24 | |
| 25 class TabRestoreServiceMock : public TabRestoreService { | |
|
sky
2011/09/20 16:24:46
When you change FilteredEntries to not take a TabR
noyau (Ping after 24h)
2011/09/20 17:09:35
Done.
| |
| 26 public: | |
| 27 class TabMock : public TabRestoreService::Tab { | |
| 28 public: | |
| 29 TabMock(const char* url, const char* title) { | |
| 30 | |
| 31 navigations.push_back(TabNavigationMock( | |
| 32 GURL(string16(ASCIIToUTF16(url))), string16(ASCIIToUTF16(title)))); | |
| 33 current_navigation_index = 0; | |
| 34 } | |
| 35 | |
| 36 }; | |
| 37 | |
| 38 TabRestoreServiceMock() : TabRestoreService(NULL) { | |
| 39 // prefill the entries | |
| 40 | |
| 41 // Two identical | |
| 42 entries_.push_back(new TabMock("http://a", "a")); | |
| 43 entries_.push_back(new TabMock("http://a", "a")); | |
| 44 | |
| 45 // Different URL | |
| 46 entries_.push_back(new TabMock("http://b", "b")); | |
| 47 entries_.push_back(new TabMock("http://c", "b")); | |
| 48 | |
| 49 // Different Title | |
| 50 entries_.push_back(new TabMock("http://d", "d")); | |
| 51 entries_.push_back(new TabMock("http://d", "e")); | |
| 52 | |
| 53 // Nothing in common | |
| 54 entries_.push_back(new TabMock("http://f", "f")); | |
| 55 entries_.push_back(new TabMock("http://g", "g")); | |
| 56 } | |
| 57 | |
| 58 }; | |
| 59 | |
|
sky
2011/09/20 16:24:46
remove one of these.
noyau (Ping after 24h)
2011/09/20 17:09:35
Done.
| |
| 60 | |
| 61 class SessionUtilsTest : public testing::Test { | |
| 62 protected: | |
| 63 virtual void SetUp() { | |
| 64 service = new TabRestoreServiceMock(); | |
| 65 } | |
| 66 | |
| 67 void TearDown() { | |
| 68 delete(service); | |
| 69 } | |
| 70 | |
| 71 TabRestoreService* service; | |
| 72 }; | |
| 73 | |
| 74 | |
| 75 TEST_F(SessionUtilsTest, SessionUtilsFilter) { | |
| 76 TabRestoreService::Entries filteredEntries; | |
|
sky
2011/09/20 16:24:46
filtered_entries.
noyau (Ping after 24h)
2011/09/20 17:09:35
Done.
| |
| 77 | |
| 78 SessionUtils::FilteredEntries(service, &filteredEntries); | |
| 79 ASSERT_EQ(7U, filteredEntries.size()); | |
| 80 | |
| 81 // The filtering should have removed the second item | |
| 82 TabRestoreService::Entries expected = service->entries(); | |
| 83 TabRestoreService::Entry* first = expected.front(); | |
| 84 expected.pop_front(); | |
| 85 expected.pop_front(); | |
| 86 expected.push_front(first); | |
| 87 ASSERT_EQ(expected, filteredEntries); | |
| 88 }; | |
| 89 | |
|
sky
2011/09/20 16:24:46
remove these newlines.
noyau (Ping after 24h)
2011/09/20 17:09:35
Done.
| |
| 90 | |
| 91 | |
| OLD | NEW |