| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 | 5 |
| 6 #include "base/basictypes.h" | 6 #include "base/basictypes.h" |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/scoped_ptr.h" | 8 #include "base/scoped_ptr.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/browser/background_contents_service.h" | 10 #include "chrome/browser/background_contents_service.h" |
| 11 #include "chrome/browser/browser_list.h" | 11 #include "chrome/browser/browser_list.h" |
| 12 #include "chrome/browser/pref_service.h" | 12 #include "chrome/browser/pref_service.h" |
| 13 #include "chrome/browser/tab_contents/background_contents.h" | 13 #include "chrome/browser/tab_contents/background_contents.h" |
| 14 #include "chrome/common/chrome_switches.h" | 14 #include "chrome/common/chrome_switches.h" |
| 15 #include "chrome/common/pref_names.h" | 15 #include "chrome/common/pref_names.h" |
| 16 #include "chrome/test/testing_browser_process.h" | 16 #include "chrome/test/testing_browser_process.h" |
| 17 #include "chrome/test/testing_profile.h" | 17 #include "chrome/test/testing_profile.h" |
| 18 #include "googleurl/src/gurl.h" | 18 #include "googleurl/src/gurl.h" |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| 20 #include "testing/platform_test.h" | 20 #include "testing/platform_test.h" |
| 21 | 21 |
| 22 class BackgroundContentsServiceTest : public testing::Test { | 22 class BackgroundContentsServiceTest : public testing::Test { |
| 23 public: | 23 public: |
| 24 BackgroundContentsServiceTest() {} | 24 BackgroundContentsServiceTest() {} |
| 25 ~BackgroundContentsServiceTest() {} | 25 ~BackgroundContentsServiceTest() {} |
| 26 void SetUp() { | 26 void SetUp() { |
| 27 command_line_.reset(new CommandLine(CommandLine::ARGUMENTS_ONLY)); | 27 command_line_.reset(new CommandLine(CommandLine::ARGUMENTS_ONLY)); |
| 28 command_line_->AppendSwitch(switches::kRestoreBackgroundContents); | |
| 29 } | 28 } |
| 30 | 29 |
| 31 DictionaryValue* GetPrefs(Profile* profile) { | 30 DictionaryValue* GetPrefs(Profile* profile) { |
| 32 return profile->GetPrefs()->GetMutableDictionary( | 31 return profile->GetPrefs()->GetMutableDictionary( |
| 33 prefs::kRegisteredBackgroundContents); | 32 prefs::kRegisteredBackgroundContents); |
| 34 } | 33 } |
| 35 | 34 |
| 36 // Returns the stored pref URL for the passed app id. | 35 // Returns the stored pref URL for the passed app id. |
| 37 std::string GetPrefURLForApp(Profile* profile, const string16& appid) { | 36 std::string GetPrefURLForApp(Profile* profile, const string16& appid) { |
| 38 DictionaryValue* pref = GetPrefs(profile); | 37 DictionaryValue* pref = GetPrefs(profile); |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 contents->Navigate(url); | 223 contents->Navigate(url); |
| 225 EXPECT_EQ(1U, GetPrefs(&profile)->size()); | 224 EXPECT_EQ(1U, GetPrefs(&profile)->size()); |
| 226 contents2->Navigate(url2); | 225 contents2->Navigate(url2); |
| 227 EXPECT_EQ(2U, GetPrefs(&profile)->size()); | 226 EXPECT_EQ(2U, GetPrefs(&profile)->size()); |
| 228 service.ShutdownAssociatedBackgroundContents(ASCIIToUTF16("appid")); | 227 service.ShutdownAssociatedBackgroundContents(ASCIIToUTF16("appid")); |
| 229 EXPECT_FALSE(service.IsTracked(contents)); | 228 EXPECT_FALSE(service.IsTracked(contents)); |
| 230 EXPECT_EQ(NULL, service.GetAppBackgroundContents(ASCIIToUTF16("appid"))); | 229 EXPECT_EQ(NULL, service.GetAppBackgroundContents(ASCIIToUTF16("appid"))); |
| 231 EXPECT_EQ(1U, GetPrefs(&profile)->size()); | 230 EXPECT_EQ(1U, GetPrefs(&profile)->size()); |
| 232 EXPECT_EQ(url2.spec(), GetPrefURLForApp(&profile, contents2->appid())); | 231 EXPECT_EQ(url2.spec(), GetPrefURLForApp(&profile, contents2->appid())); |
| 233 } | 232 } |
| OLD | NEW |