Index: chrome/browser/sessions/tab_restore_service_browsertest.cc |
diff --git a/chrome/browser/sessions/tab_restore_service_browsertest.cc b/chrome/browser/sessions/tab_restore_service_browsertest.cc |
index 4cb97d1eec74be5a4fe94f3ba8f30ed6796e764f..4b183126d8973d7c3ca75c4e090d69317df19823 100644 |
--- a/chrome/browser/sessions/tab_restore_service_browsertest.cc |
+++ b/chrome/browser/sessions/tab_restore_service_browsertest.cc |
@@ -8,9 +8,11 @@ |
#include "chrome/browser/sessions/session_service.h" |
#include "chrome/browser/sessions/session_types.h" |
#include "chrome/browser/sessions/tab_restore_service.h" |
+#include "chrome/browser/ui/browser_window.h" |
#include "chrome/common/url_constants.h" |
#include "chrome/test/base/chrome_render_view_host_test_harness.h" |
#include "chrome/test/base/chrome_render_view_test.h" |
+#include "chrome/test/base/in_process_browser_test.h" |
#include "chrome/test/base/testing_profile.h" |
#include "content/browser/tab_contents/test_tab_contents.h" |
#include "content/public/browser/navigation_controller.h" |
@@ -20,6 +22,7 @@ |
#include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" |
typedef TabRestoreService::Tab Tab; |
+typedef TabRestoreService::Window Window; |
using content::NavigationEntry; |
@@ -97,7 +100,7 @@ class TabRestoreServiceTest : public ChromeRenderViewHostTestHarness { |
SessionServiceFactory::GetForProfile(profile()); |
SessionID tab_id; |
SessionID window_id; |
- session_service->SetWindowType(window_id, Browser::TYPE_TABBED); |
+ session_service->SetWindowType(window_id, Browser::TYPE_TABBED, false); |
session_service->SetTabWindow(window_id, tab_id); |
session_service->SetTabIndexInWindow(window_id, tab_id, 0); |
session_service->SetSelectedTabInWindow(window_id, 0); |
@@ -108,6 +111,23 @@ class TabRestoreServiceTest : public ChromeRenderViewHostTestHarness { |
session_service->UpdateTabNavigation(window_id, tab_id, 0, *entry.get()); |
} |
+ // Adds a window with one tab and url to the profile's session service. |
+ // If |pinned| is true, the tab is marked as pinned in the session service. |
+ void AddApplicationWindowToSessionService() { |
+ SessionService* session_service = |
+ SessionServiceFactory::GetForProfile(profile()); |
+ SessionID tab_id; |
+ SessionID window_id; |
+ session_service->SetWindowType(window_id, Browser::TYPE_POPUP, true); |
+ session_service->SetWindowAppName(window_id, "TestApp"); |
+ session_service->SetTabWindow(window_id, tab_id); |
+ session_service->SetTabIndexInWindow(window_id, tab_id, 0); |
+ session_service->SetSelectedTabInWindow(window_id, 0); |
+ scoped_ptr<NavigationEntry> entry(NavigationEntry::Create());; |
+ entry->SetURL(url1_); |
+ session_service->UpdateTabNavigation(window_id, tab_id, 0, *entry.get()); |
+ } |
+ |
// Creates a SessionService and assigns it to the Profile. The SessionService |
// is configured with a single window with a single tab pointing at url1_ by |
// way of AddWindowWithOneTabToSessionService. If |pinned| is true, the |
@@ -249,6 +269,34 @@ TEST_F(TabRestoreServiceTest, RestorePinnedAndApp) { |
EXPECT_TRUE(extension_app_id == tab->extension_app_id); |
} |
+// We only restore apps on chromeos. |
+#if defined(OS_CHROMEOS) |
+typedef InProcessBrowserTest TabRestoreServiceBrowserTest; |
+IN_PROC_BROWSER_TEST_F(TabRestoreServiceBrowserTest, RestoreApp) { |
+ Profile* profile = browser()->profile(); |
+ const char* app_name = "TestApp"; |
+ |
+ Browser* app_browser = |
+ Browser::CreateForApp(Browser::TYPE_POPUP, |
+ app_name, |
+ gfx::Rect(), |
+ profile); |
+ |
+ app_browser->window()->Close(); |
+ TabRestoreService trs(profile); |
+ // One entry should be created. |
+ ASSERT_EQ(1U, trs.entries().size()); |
+ const TabRestoreService::Entry* restored_entry = trs.entries().front(); |
+ |
+ // It should be a window with an app. |
+ ASSERT_EQ(TabRestoreService::WINDOW, restored_entry->type); |
+ const Window* restored_window = |
+ static_cast<const Window*>(restored_entry); |
+ EXPECT_EQ(app_name, restored_window->app_name); |
+ |
+} |
+#endif |
+ |
// Make sure we persist entries to disk that have post data. |
TEST_F(TabRestoreServiceTest, DontPersistPostData) { |
AddThreeNavigations(); |