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.
5 // TODO(jamescook): Why does this test run on all Aura platforms, instead of
6 // only Chrome OS or Ash?
9 #include "components/sessions/core/persistent_tab_restore_service.h"
11 #include "chrome/browser/chrome_notification_types.h"
12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/sessions/tab_restore_service_factory.h"
14 #include "chrome/browser/ui/browser_window.h"
15 #include "chrome/test/base/in_process_browser_test.h"
16 #include "content/public/browser/notification_source.h"
17 #include "content/public/browser/notification_types.h"
18 #include "content/public/test/test_utils.h"
19 #include "testing/gtest/include/gtest/gtest.h"
21 typedef sessions::TabRestoreService::Window Window
;
23 typedef InProcessBrowserTest PersistentTabRestoreServiceBrowserTest
;
25 IN_PROC_BROWSER_TEST_F(PersistentTabRestoreServiceBrowserTest
, RestoreApp
) {
26 Profile
* profile
= browser()->profile();
27 sessions::TabRestoreService
* trs
=
28 TabRestoreServiceFactory::GetForProfile(profile
);
29 const char* app_name
= "TestApp";
31 Browser
* app_browser
= CreateBrowserForApp(app_name
, profile
);
32 app_browser
->window()->Close();
33 content::WindowedNotificationObserver
observer(
34 chrome::NOTIFICATION_BROWSER_CLOSED
,
35 content::Source
<Browser
>(app_browser
));
38 // One entry should be created.
39 ASSERT_EQ(1U, trs
->entries().size());
40 const sessions::TabRestoreService::Entry
* restored_entry
=
41 trs
->entries().front();
43 // It should be a window with an app.
44 ASSERT_EQ(sessions::TabRestoreService::WINDOW
, restored_entry
->type
);
45 const Window
* restored_window
=
46 static_cast<const Window
*>(restored_entry
);
47 EXPECT_EQ(app_name
, restored_window
->app_name
);
50 #endif // defined(USE_AURA)