| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/extensions/api/sessions/sessions_api.h" | 5 #include "chrome/browser/extensions/api/sessions/sessions_api.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
| 9 #include "base/strings/pattern.h" |
| 9 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| 10 #include "chrome/browser/extensions/api/tabs/tabs_api.h" | 11 #include "chrome/browser/extensions/api/tabs/tabs_api.h" |
| 11 #include "chrome/browser/extensions/extension_apitest.h" | 12 #include "chrome/browser/extensions/extension_apitest.h" |
| 12 #include "chrome/browser/extensions/extension_function_test_utils.h" | 13 #include "chrome/browser/extensions/extension_function_test_utils.h" |
| 13 #include "chrome/browser/profiles/profile_manager.h" | 14 #include "chrome/browser/profiles/profile_manager.h" |
| 14 #include "chrome/browser/sync/profile_sync_components_factory_mock.h" | 15 #include "chrome/browser/sync/profile_sync_components_factory_mock.h" |
| 15 #include "chrome/browser/sync/profile_sync_service.h" | 16 #include "chrome/browser/sync/profile_sync_service.h" |
| 16 #include "chrome/browser/sync/profile_sync_service_factory.h" | 17 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 17 #include "chrome/browser/sync/profile_sync_service_mock.h" | 18 #include "chrome/browser/sync/profile_sync_service_mock.h" |
| 18 #include "chrome/common/chrome_paths.h" | 19 #include "chrome/common/chrome_paths.h" |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 EXPECT_TRUE(windows->GetDictionary(i, &window)); | 341 EXPECT_TRUE(windows->GetDictionary(i, &window)); |
| 341 if (api_test_utils::GetInteger(window, "id") == restored_id) | 342 if (api_test_utils::GetInteger(window, "id") == restored_id) |
| 342 break; | 343 break; |
| 343 } | 344 } |
| 344 EXPECT_EQ(restored_id, api_test_utils::GetInteger(window, "id")); | 345 EXPECT_EQ(restored_id, api_test_utils::GetInteger(window, "id")); |
| 345 } | 346 } |
| 346 | 347 |
| 347 IN_PROC_BROWSER_TEST_F(ExtensionSessionsTest, RestoreForeignSessionInvalidId) { | 348 IN_PROC_BROWSER_TEST_F(ExtensionSessionsTest, RestoreForeignSessionInvalidId) { |
| 348 CreateSessionModels(); | 349 CreateSessionModels(); |
| 349 | 350 |
| 350 EXPECT_TRUE(MatchPattern(utils::RunFunctionAndReturnError( | 351 EXPECT_TRUE(base::MatchPattern(utils::RunFunctionAndReturnError( |
| 351 CreateFunction<SessionsRestoreFunction>(true).get(), | 352 CreateFunction<SessionsRestoreFunction>(true).get(), |
| 352 "[\"tag3.0\"]", | 353 "[\"tag3.0\"]", |
| 353 browser_), "Invalid session id: \"tag3.0\".")); | 354 browser_), "Invalid session id: \"tag3.0\".")); |
| 354 } | 355 } |
| 355 | 356 |
| 356 IN_PROC_BROWSER_TEST_F(ExtensionSessionsTest, RestoreInIncognito) { | 357 IN_PROC_BROWSER_TEST_F(ExtensionSessionsTest, RestoreInIncognito) { |
| 357 CreateSessionModels(); | 358 CreateSessionModels(); |
| 358 | 359 |
| 359 EXPECT_TRUE(MatchPattern(utils::RunFunctionAndReturnError( | 360 EXPECT_TRUE(base::MatchPattern(utils::RunFunctionAndReturnError( |
| 360 CreateFunction<SessionsRestoreFunction>(true).get(), | 361 CreateFunction<SessionsRestoreFunction>(true).get(), |
| 361 "[\"1\"]", | 362 "[\"1\"]", |
| 362 CreateIncognitoBrowser()), | 363 CreateIncognitoBrowser()), |
| 363 "Can not restore sessions in incognito mode.")); | 364 "Can not restore sessions in incognito mode.")); |
| 364 } | 365 } |
| 365 | 366 |
| 366 IN_PROC_BROWSER_TEST_F(ExtensionSessionsTest, GetRecentlyClosedIncognito) { | 367 IN_PROC_BROWSER_TEST_F(ExtensionSessionsTest, GetRecentlyClosedIncognito) { |
| 367 scoped_ptr<base::ListValue> result(utils::ToList( | 368 scoped_ptr<base::ListValue> result(utils::ToList( |
| 368 utils::RunFunctionAndReturnSingleResult( | 369 utils::RunFunctionAndReturnSingleResult( |
| 369 CreateFunction<SessionsGetRecentlyClosedFunction>(true).get(), | 370 CreateFunction<SessionsGetRecentlyClosedFunction>(true).get(), |
| (...skipping 13 matching lines...) Expand all Loading... |
| 383 return; | 384 return; |
| 384 #endif | 385 #endif |
| 385 | 386 |
| 386 ASSERT_TRUE(RunExtensionSubtest("sessions", | 387 ASSERT_TRUE(RunExtensionSubtest("sessions", |
| 387 "sessions.html")) << message_; | 388 "sessions.html")) << message_; |
| 388 } | 389 } |
| 389 | 390 |
| 390 } // namespace | 391 } // namespace |
| 391 | 392 |
| 392 } // namespace extensions | 393 } // namespace extensions |
| OLD | NEW |