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

Side by Side Diff: chrome/browser/sessions/session_service_unittest.cc

Issue 8342048: Make NotificationService an interface in the content namespace, and switch callers to use it. Mov... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/sessions/session_service.cc ('k') | chrome/browser/sidebar/sidebar_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/file_util.h" 5 #include "base/file_util.h"
6 #include "base/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
7 #include "base/memory/scoped_vector.h" 7 #include "base/memory/scoped_vector.h"
8 #include "base/path_service.h" 8 #include "base/path_service.h"
9 #include "base/scoped_temp_dir.h" 9 #include "base/scoped_temp_dir.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
11 #include "base/string_number_conversions.h" 11 #include "base/string_number_conversions.h"
12 #include "base/time.h" 12 #include "base/time.h"
13 #include "base/utf_string_conversions.h" 13 #include "base/utf_string_conversions.h"
14 #include "chrome/browser/defaults.h" 14 #include "chrome/browser/defaults.h"
15 #include "chrome/browser/sessions/session_backend.h" 15 #include "chrome/browser/sessions/session_backend.h"
16 #include "chrome/browser/sessions/session_service.h" 16 #include "chrome/browser/sessions/session_service.h"
17 #include "chrome/browser/sessions/session_service_test_helper.h" 17 #include "chrome/browser/sessions/session_service_test_helper.h"
18 #include "chrome/browser/sessions/session_types.h" 18 #include "chrome/browser/sessions/session_types.h"
19 #include "chrome/common/chrome_notification_types.h" 19 #include "chrome/common/chrome_notification_types.h"
20 #include "chrome/common/chrome_paths.h" 20 #include "chrome/common/chrome_paths.h"
21 #include "chrome/test/base/browser_with_test_window_test.h" 21 #include "chrome/test/base/browser_with_test_window_test.h"
22 #include "chrome/test/base/testing_profile.h" 22 #include "chrome/test/base/testing_profile.h"
23 #include "content/browser/tab_contents/navigation_entry.h" 23 #include "content/browser/tab_contents/navigation_entry.h"
24 #include "content/public/browser/notification_observer.h" 24 #include "content/public/browser/notification_observer.h"
25 #include "content/public/browser/notification_registrar.h" 25 #include "content/public/browser/notification_registrar.h"
26 #include "content/common/notification_service.h" 26 #include "content/public/browser/notification_service.h"
27 #include "testing/gtest/include/gtest/gtest.h" 27 #include "testing/gtest/include/gtest/gtest.h"
28 28
29 class SessionServiceTest : public BrowserWithTestWindowTest, 29 class SessionServiceTest : public BrowserWithTestWindowTest,
30 public content::NotificationObserver { 30 public content::NotificationObserver {
31 public: 31 public:
32 SessionServiceTest() : window_bounds(0, 1, 2, 3), sync_save_count_(0){} 32 SessionServiceTest() : window_bounds(0, 1, 2, 3), sync_save_count_(0){}
33 33
34 protected: 34 protected:
35 virtual void SetUp() { 35 virtual void SetUp() {
36 BrowserWithTestWindowTest::SetUp(); 36 BrowserWithTestWindowTest::SetUp();
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 CancelableRequestConsumer consumer; 643 CancelableRequestConsumer consumer;
644 GetCurrentSessionCallbackHandler handler; 644 GetCurrentSessionCallbackHandler handler;
645 service()->GetCurrentSession(&consumer, 645 service()->GetCurrentSession(&consumer,
646 NewCallback(&handler, &GetCurrentSessionCallbackHandler::OnGotSession)); 646 NewCallback(&handler, &GetCurrentSessionCallbackHandler::OnGotSession));
647 } 647 }
648 648
649 // Test that the notification for SESSION_SERVICE_SAVED is working properly. 649 // Test that the notification for SESSION_SERVICE_SAVED is working properly.
650 TEST_F(SessionServiceTest, SavedSessionNotification) { 650 TEST_F(SessionServiceTest, SavedSessionNotification) {
651 content::NotificationRegistrar registrar_; 651 content::NotificationRegistrar registrar_;
652 registrar_.Add(this, chrome::NOTIFICATION_SESSION_SERVICE_SAVED, 652 registrar_.Add(this, chrome::NOTIFICATION_SESSION_SERVICE_SAVED,
653 NotificationService::AllSources()); 653 content::NotificationService::AllSources());
654 service()->Save(); 654 service()->Save();
655 EXPECT_EQ(sync_save_count_, 1); 655 EXPECT_EQ(sync_save_count_, 1);
656 } 656 }
657 657
658 // Makes sure a tab closed by a user gesture is not restored. 658 // Makes sure a tab closed by a user gesture is not restored.
659 TEST_F(SessionServiceTest, CloseTabUserGesture) { 659 TEST_F(SessionServiceTest, CloseTabUserGesture) {
660 SessionID tab_id; 660 SessionID tab_id;
661 ASSERT_NE(window_id.id(), tab_id.id()); 661 ASSERT_NE(window_id.id(), tab_id.id());
662 662
663 TabNavigation nav1(0, GURL("http://google.com"), 663 TabNavigation nav1(0, GURL("http://google.com"),
664 GURL("http://www.referrer.com"), 664 GURL("http://www.referrer.com"),
665 ASCIIToUTF16("abc"), "def", 665 ASCIIToUTF16("abc"), "def",
666 content::PAGE_TRANSITION_QUALIFIER_MASK); 666 content::PAGE_TRANSITION_QUALIFIER_MASK);
667 667
668 helper_.PrepareTabInWindow(window_id, tab_id, 0, true); 668 helper_.PrepareTabInWindow(window_id, tab_id, 0, true);
669 UpdateNavigation(window_id, tab_id, nav1, 0, true); 669 UpdateNavigation(window_id, tab_id, nav1, 0, true);
670 service()->TabClosed(window_id, tab_id, true); 670 service()->TabClosed(window_id, tab_id, true);
671 671
672 ScopedVector<SessionWindow> windows; 672 ScopedVector<SessionWindow> windows;
673 ReadWindows(&(windows.get())); 673 ReadWindows(&(windows.get()));
674 674
675 ASSERT_TRUE(windows->empty()); 675 ASSERT_TRUE(windows->empty());
676 } 676 }
OLDNEW
« no previous file with comments | « chrome/browser/sessions/session_service.cc ('k') | chrome/browser/sidebar/sidebar_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698