| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
| 7 #include "base/files/file_util.h" | 7 #include "base/files/file_util.h" |
| 8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/memory/scoped_vector.h" | 10 #include "base/memory/scoped_vector.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 using content::NavigationEntry; | 40 using content::NavigationEntry; |
| 41 using sessions::SerializedNavigationEntry; | 41 using sessions::SerializedNavigationEntry; |
| 42 using sessions::SerializedNavigationEntryTestHelper; | 42 using sessions::SerializedNavigationEntryTestHelper; |
| 43 | 43 |
| 44 class SessionServiceTest : public BrowserWithTestWindowTest, | 44 class SessionServiceTest : public BrowserWithTestWindowTest, |
| 45 public content::NotificationObserver { | 45 public content::NotificationObserver { |
| 46 public: | 46 public: |
| 47 SessionServiceTest() : window_bounds(0, 1, 2, 3), sync_save_count_(0) {} | 47 SessionServiceTest() : window_bounds(0, 1, 2, 3), sync_save_count_(0) {} |
| 48 | 48 |
| 49 protected: | 49 protected: |
| 50 virtual void SetUp() { | 50 void SetUp() override { |
| 51 BrowserWithTestWindowTest::SetUp(); | 51 BrowserWithTestWindowTest::SetUp(); |
| 52 | 52 |
| 53 profile_manager_.reset( | 53 profile_manager_.reset( |
| 54 new TestingProfileManager(TestingBrowserProcess::GetGlobal())); | 54 new TestingProfileManager(TestingBrowserProcess::GetGlobal())); |
| 55 ASSERT_TRUE(profile_manager_->SetUp()); | 55 ASSERT_TRUE(profile_manager_->SetUp()); |
| 56 | 56 |
| 57 std::string b = base::Int64ToString(base::Time::Now().ToInternalValue()); | 57 std::string b = base::Int64ToString(base::Time::Now().ToInternalValue()); |
| 58 TestingProfile* profile = profile_manager_->CreateTestingProfile(b); | 58 TestingProfile* profile = profile_manager_->CreateTestingProfile(b); |
| 59 SessionService* session_service = new SessionService(profile); | 59 SessionService* session_service = new SessionService(profile); |
| 60 path_ = profile->GetPath(); | 60 path_ = profile->GetPath(); |
| 61 | 61 |
| 62 helper_.SetService(session_service); | 62 helper_.SetService(session_service); |
| 63 | 63 |
| 64 service()->SetWindowType( | 64 service()->SetWindowType( |
| 65 window_id, Browser::TYPE_TABBED, SessionService::TYPE_NORMAL); | 65 window_id, Browser::TYPE_TABBED, SessionService::TYPE_NORMAL); |
| 66 service()->SetWindowBounds(window_id, | 66 service()->SetWindowBounds(window_id, |
| 67 window_bounds, | 67 window_bounds, |
| 68 ui::SHOW_STATE_NORMAL); | 68 ui::SHOW_STATE_NORMAL); |
| 69 } | 69 } |
| 70 | 70 |
| 71 // Upon notification, increment the sync_save_count variable | 71 // Upon notification, increment the sync_save_count variable |
| 72 void Observe(int type, | 72 void Observe(int type, |
| 73 const content::NotificationSource& source, | 73 const content::NotificationSource& source, |
| 74 const content::NotificationDetails& details) override { | 74 const content::NotificationDetails& details) override { |
| 75 ASSERT_EQ(type, chrome::NOTIFICATION_SESSION_SERVICE_SAVED); | 75 ASSERT_EQ(type, chrome::NOTIFICATION_SESSION_SERVICE_SAVED); |
| 76 sync_save_count_++; | 76 sync_save_count_++; |
| 77 } | 77 } |
| 78 | 78 |
| 79 virtual void TearDown() { | 79 void TearDown() override { |
| 80 helper_.SetService(NULL); | 80 helper_.SetService(NULL); |
| 81 BrowserWithTestWindowTest::TearDown(); | 81 BrowserWithTestWindowTest::TearDown(); |
| 82 } | 82 } |
| 83 | 83 |
| 84 void UpdateNavigation( | 84 void UpdateNavigation( |
| 85 const SessionID& window_id, | 85 const SessionID& window_id, |
| 86 const SessionID& tab_id, | 86 const SessionID& tab_id, |
| 87 const SerializedNavigationEntry& navigation, | 87 const SerializedNavigationEntry& navigation, |
| 88 bool select) { | 88 bool select) { |
| 89 service()->UpdateTabNavigation(window_id, tab_id, navigation); | 89 service()->UpdateTabNavigation(window_id, tab_id, navigation); |
| (...skipping 926 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1016 &cancelable_task_tracker); | 1016 &cancelable_task_tracker); |
| 1017 helper_.RunTaskOnBackendThread( | 1017 helper_.RunTaskOnBackendThread( |
| 1018 FROM_HERE, | 1018 FROM_HERE, |
| 1019 base::Bind(&PostBackToThread, | 1019 base::Bind(&PostBackToThread, |
| 1020 base::Unretained(base::MessageLoop::current()), | 1020 base::Unretained(base::MessageLoop::current()), |
| 1021 base::Unretained(&run_loop))); | 1021 base::Unretained(&run_loop))); |
| 1022 delete helper_.ReleaseService(); | 1022 delete helper_.ReleaseService(); |
| 1023 event.Signal(); | 1023 event.Signal(); |
| 1024 run_loop.Run(); | 1024 run_loop.Run(); |
| 1025 } | 1025 } |
| OLD | NEW |