| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "chrome/browser/sessions/session_service.h" | 5 #include "chrome/browser/sessions/session_service.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 path_ = profile->GetPath(); | 68 path_ = profile->GetPath(); |
| 69 | 69 |
| 70 helper_.SetService(session_service); | 70 helper_.SetService(session_service); |
| 71 | 71 |
| 72 service()->SetWindowType(window_id, | 72 service()->SetWindowType(window_id, |
| 73 Browser::TYPE_TABBED, | 73 Browser::TYPE_TABBED, |
| 74 SessionService::TYPE_NORMAL); | 74 SessionService::TYPE_NORMAL); |
| 75 service()->SetWindowBounds(window_id, | 75 service()->SetWindowBounds(window_id, |
| 76 window_bounds, | 76 window_bounds, |
| 77 ui::SHOW_STATE_NORMAL); | 77 ui::SHOW_STATE_NORMAL); |
| 78 service()->SetWindowWorkspace(window_id, window_workspace); |
| 78 } | 79 } |
| 79 | 80 |
| 80 // Upon notification, increment the sync_save_count variable | 81 // Upon notification, increment the sync_save_count variable |
| 81 void Observe(int type, | 82 void Observe(int type, |
| 82 const content::NotificationSource& source, | 83 const content::NotificationSource& source, |
| 83 const content::NotificationDetails& details) override { | 84 const content::NotificationDetails& details) override { |
| 84 ASSERT_EQ(type, chrome::NOTIFICATION_SESSION_SERVICE_SAVED); | 85 ASSERT_EQ(type, chrome::NOTIFICATION_SESSION_SERVICE_SAVED); |
| 85 sync_save_count_++; | 86 sync_save_count_++; |
| 86 } | 87 } |
| 87 | 88 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 window2_bounds, | 172 window2_bounds, |
| 172 ui::SHOW_STATE_MAXIMIZED); | 173 ui::SHOW_STATE_MAXIMIZED); |
| 173 helper_.PrepareTabInWindow(window2_id, tab2_id, 0, true); | 174 helper_.PrepareTabInWindow(window2_id, tab2_id, 0, true); |
| 174 UpdateNavigation(window2_id, tab2_id, *nav2, true); | 175 UpdateNavigation(window2_id, tab2_id, *nav2, true); |
| 175 } | 176 } |
| 176 | 177 |
| 177 SessionService* service() { return helper_.service(); } | 178 SessionService* service() { return helper_.service(); } |
| 178 | 179 |
| 179 const gfx::Rect window_bounds; | 180 const gfx::Rect window_bounds; |
| 180 | 181 |
| 182 const std::string window_workspace = "abc"; |
| 183 |
| 181 SessionID window_id; | 184 SessionID window_id; |
| 182 | 185 |
| 183 int sync_save_count_; | 186 int sync_save_count_; |
| 184 | 187 |
| 185 // Path used in testing. | 188 // Path used in testing. |
| 186 base::ScopedTempDir temp_dir_; | 189 base::ScopedTempDir temp_dir_; |
| 187 base::FilePath path_; | 190 base::FilePath path_; |
| 188 | 191 |
| 189 SessionServiceTestHelper helper_; | 192 SessionServiceTestHelper helper_; |
| 190 std::unique_ptr<TestingProfileManager> profile_manager_; | 193 std::unique_ptr<TestingProfileManager> profile_manager_; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 201 GURL("http://original.request.com"), &nav1); | 204 GURL("http://original.request.com"), &nav1); |
| 202 | 205 |
| 203 helper_.PrepareTabInWindow(window_id, tab_id, 0, true); | 206 helper_.PrepareTabInWindow(window_id, tab_id, 0, true); |
| 204 UpdateNavigation(window_id, tab_id, nav1, true); | 207 UpdateNavigation(window_id, tab_id, nav1, true); |
| 205 | 208 |
| 206 ScopedVector<sessions::SessionWindow> windows; | 209 ScopedVector<sessions::SessionWindow> windows; |
| 207 ReadWindows(&(windows.get()), NULL); | 210 ReadWindows(&(windows.get()), NULL); |
| 208 | 211 |
| 209 ASSERT_EQ(1U, windows.size()); | 212 ASSERT_EQ(1U, windows.size()); |
| 210 ASSERT_TRUE(window_bounds == windows[0]->bounds); | 213 ASSERT_TRUE(window_bounds == windows[0]->bounds); |
| 214 ASSERT_EQ(window_workspace, windows[0]->workspace); |
| 211 ASSERT_EQ(0, windows[0]->selected_tab_index); | 215 ASSERT_EQ(0, windows[0]->selected_tab_index); |
| 212 ASSERT_EQ(window_id.id(), windows[0]->window_id.id()); | 216 ASSERT_EQ(window_id.id(), windows[0]->window_id.id()); |
| 213 ASSERT_EQ(1U, windows[0]->tabs.size()); | 217 ASSERT_EQ(1U, windows[0]->tabs.size()); |
| 214 ASSERT_EQ(sessions::SessionWindow::TYPE_TABBED, windows[0]->type); | 218 ASSERT_EQ(sessions::SessionWindow::TYPE_TABBED, windows[0]->type); |
| 215 | 219 |
| 216 sessions::SessionTab* tab = windows[0]->tabs[0]; | 220 sessions::SessionTab* tab = windows[0]->tabs[0]; |
| 217 helper_.AssertTabEquals(window_id, tab_id, 0, 0, 1, *tab); | 221 helper_.AssertTabEquals(window_id, tab_id, 0, 0, 1, *tab); |
| 218 | 222 |
| 219 helper_.AssertNavigationEquals(nav1, tab->navigations[0]); | 223 helper_.AssertNavigationEquals(nav1, tab->navigations[0]); |
| 220 } | 224 } |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 SessionID tab_id; | 506 SessionID tab_id; |
| 503 SessionID tab2_id; | 507 SessionID tab2_id; |
| 504 ASSERT_NE(window2_id.id(), window_id.id()); | 508 ASSERT_NE(window2_id.id(), window_id.id()); |
| 505 | 509 |
| 506 service()->SetWindowType(window2_id, | 510 service()->SetWindowType(window2_id, |
| 507 Browser::TYPE_POPUP, | 511 Browser::TYPE_POPUP, |
| 508 SessionService::TYPE_NORMAL); | 512 SessionService::TYPE_NORMAL); |
| 509 service()->SetWindowBounds(window2_id, | 513 service()->SetWindowBounds(window2_id, |
| 510 window_bounds, | 514 window_bounds, |
| 511 ui::SHOW_STATE_NORMAL); | 515 ui::SHOW_STATE_NORMAL); |
| 516 service()->SetWindowWorkspace(window2_id, window_workspace); |
| 512 | 517 |
| 513 SerializedNavigationEntry nav1 = | 518 SerializedNavigationEntry nav1 = |
| 514 SerializedNavigationEntryTestHelper::CreateNavigation( | 519 SerializedNavigationEntryTestHelper::CreateNavigation( |
| 515 "http://google.com", "abc"); | 520 "http://google.com", "abc"); |
| 516 SerializedNavigationEntry nav2 = | 521 SerializedNavigationEntry nav2 = |
| 517 SerializedNavigationEntryTestHelper::CreateNavigation( | 522 SerializedNavigationEntryTestHelper::CreateNavigation( |
| 518 "http://google2.com", "abcd"); | 523 "http://google2.com", "abcd"); |
| 519 | 524 |
| 520 helper_.PrepareTabInWindow(window_id, tab_id, 0, true); | 525 helper_.PrepareTabInWindow(window_id, tab_id, 0, true); |
| 521 UpdateNavigation(window_id, tab_id, nav1, true); | 526 UpdateNavigation(window_id, tab_id, nav1, true); |
| (...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1038 &cancelable_task_tracker); | 1043 &cancelable_task_tracker); |
| 1039 helper_.RunTaskOnBackendThread( | 1044 helper_.RunTaskOnBackendThread( |
| 1040 FROM_HERE, | 1045 FROM_HERE, |
| 1041 base::Bind(&PostBackToThread, | 1046 base::Bind(&PostBackToThread, |
| 1042 base::Unretained(base::MessageLoop::current()), | 1047 base::Unretained(base::MessageLoop::current()), |
| 1043 base::Unretained(&run_loop))); | 1048 base::Unretained(&run_loop))); |
| 1044 delete helper_.ReleaseService(); | 1049 delete helper_.ReleaseService(); |
| 1045 event.Signal(); | 1050 event.Signal(); |
| 1046 run_loop.Run(); | 1051 run_loop.Run(); |
| 1047 } | 1052 } |
| OLD | NEW |