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

Unified Diff: chrome/browser/ui/toolbar/recent_tabs_builder_test_helper.cc

Issue 11316127: Alternate NTP: Limit width of tab titles in recent tabs menu (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address review comments Created 8 years, 1 month 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
Index: chrome/browser/ui/toolbar/recent_tabs_builder_test_helper.cc
diff --git a/chrome/browser/ui/toolbar/recent_tabs_builder_test_helper.cc b/chrome/browser/ui/toolbar/recent_tabs_builder_test_helper.cc
index dba7d8f0001e37b95581090610c3686ace0fa087..1a267dbd6e4959e89f9e06dc3f68a136bbaa288b 100644
--- a/chrome/browser/ui/toolbar/recent_tabs_builder_test_helper.cc
+++ b/chrome/browser/ui/toolbar/recent_tabs_builder_test_helper.cc
@@ -56,6 +56,25 @@ std::string ToTabUrl(SessionID::id_type session_id,
} // namespace
+struct RecentTabsBuilderTestHelper::TabInfo {
+ TabInfo() : id(0) {}
+ SessionID::id_type id;
+ base::Time timestamp;
+ string16 title;
+};
+struct RecentTabsBuilderTestHelper::WindowInfo {
+ WindowInfo() : id(0) {}
+ ~WindowInfo() {}
+ SessionID::id_type id;
+ std::vector<TabInfo> tabs;
+};
+struct RecentTabsBuilderTestHelper::SessionInfo {
+ SessionInfo() : id(0) {}
+ ~SessionInfo() {}
+ SessionID::id_type id;
+ std::vector<WindowInfo> windows;
+};
+
RecentTabsBuilderTestHelper::RecentTabsBuilderTestHelper() {
start_time_ = base::Time::Now();
}
@@ -110,15 +129,17 @@ SessionID::id_type RecentTabsBuilderTestHelper::GetWindowID(int session_index,
void RecentTabsBuilderTestHelper::AddTab(int session_index, int window_index) {
base::Time timestamp =
start_time_ + base::TimeDelta::FromMinutes(base::RandUint64());
- AddTabWithTimestamp(session_index, window_index, timestamp);
+ AddTabWithInfo(session_index, window_index, timestamp, string16());
}
-void RecentTabsBuilderTestHelper::AddTabWithTimestamp(int session_index,
- int window_index,
- base::Time timestamp) {
+void RecentTabsBuilderTestHelper::AddTabWithInfo(int session_index,
+ int window_index,
+ base::Time timestamp,
+ const string16& title) {
TabInfo tab_info;
tab_info.id = CreateUniqueID();
tab_info.timestamp = timestamp;
+ tab_info.title = title;
sessions_[session_index].windows[window_index].tabs.push_back(tab_info);
}
@@ -140,6 +161,20 @@ base::Time RecentTabsBuilderTestHelper::GetTabTimestamp(int session_index,
.tabs[tab_index].timestamp;
}
+string16 RecentTabsBuilderTestHelper::GetTabTitle(int session_index,
+ int window_index,
+ int tab_index) {
+ string16 title =
+ sessions_[session_index].windows[window_index].tabs[tab_index].title;
+ if (title.empty()) {
+ title = UTF8ToUTF16(ToTabTitle(
+ GetSessionID(session_index),
+ GetWindowID(session_index, window_index),
+ GetTabID(session_index, window_index, tab_index)));
+ }
+ return title;
+}
+
void RecentTabsBuilderTestHelper::RegisterRecentTabs(
browser_sync::SessionModelAssociator* associator) {
for (int s = 0; s < GetSessionCount(); ++s) {
@@ -178,8 +213,7 @@ RecentTabsBuilderTestHelper::GetTabTitlesSortedByRecency() {
for (int w = 0; w < GetWindowCount(s); ++w) {
for (int t = 0; t < GetTabCount(s, w); ++t) {
TitleTimestampPair pair;
- pair.title = UTF8ToUTF16(ToTabTitle(
- GetSessionID(s), GetWindowID(s, w), GetTabID(s, w, t)));
+ pair.title = GetTabTitle(s, w, t);
pair.timestamp = GetTabTimestamp(s, w, t);
tabs.push_back(pair);
}
@@ -237,14 +271,7 @@ void RecentTabsBuilderTestHelper::BuildTabSpecifics(
sync_pb::TabNavigation* navigation = tab->add_navigation();
navigation->set_virtual_url(ToTabUrl(session_id, window_id, tab_id));
navigation->set_referrer("referrer");
- navigation->set_title(ToTabTitle(session_id, window_id, tab_id));
+ navigation->set_title(UTF16ToUTF8(GetTabTitle(
+ session_index, window_index, tab_index)));
navigation->set_page_transition(sync_pb::SyncEnums_PageTransition_TYPED);
}
-
-RecentTabsBuilderTestHelper::WindowInfo::WindowInfo() {}
-
-RecentTabsBuilderTestHelper::WindowInfo::~WindowInfo() {}
-
-RecentTabsBuilderTestHelper::SessionInfo::SessionInfo() {}
-
-RecentTabsBuilderTestHelper::SessionInfo::~SessionInfo() {}
« no previous file with comments | « chrome/browser/ui/toolbar/recent_tabs_builder_test_helper.h ('k') | chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698