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/prefs/pref_service.h" | 12 #include "chrome/browser/prefs/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::NO_PROGRAM)); |
28 } | 28 } |
29 | 29 |
30 DictionaryValue* GetPrefs(Profile* profile) { | 30 DictionaryValue* GetPrefs(Profile* profile) { |
31 return profile->GetPrefs()->GetMutableDictionary( | 31 return profile->GetPrefs()->GetMutableDictionary( |
32 prefs::kRegisteredBackgroundContents); | 32 prefs::kRegisteredBackgroundContents); |
33 } | 33 } |
34 | 34 |
35 // Returns the stored pref URL for the passed app id. | 35 // Returns the stored pref URL for the passed app id. |
36 std::string GetPrefURLForApp(Profile* profile, const string16& appid) { | 36 std::string GetPrefURLForApp(Profile* profile, const string16& appid) { |
37 DictionaryValue* pref = GetPrefs(profile); | 37 DictionaryValue* pref = GetPrefs(profile); |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 contents->Navigate(url); | 220 contents->Navigate(url); |
221 EXPECT_EQ(1U, GetPrefs(&profile)->size()); | 221 EXPECT_EQ(1U, GetPrefs(&profile)->size()); |
222 contents2->Navigate(url2); | 222 contents2->Navigate(url2); |
223 EXPECT_EQ(2U, GetPrefs(&profile)->size()); | 223 EXPECT_EQ(2U, GetPrefs(&profile)->size()); |
224 service.ShutdownAssociatedBackgroundContents(ASCIIToUTF16("appid")); | 224 service.ShutdownAssociatedBackgroundContents(ASCIIToUTF16("appid")); |
225 EXPECT_FALSE(service.IsTracked(contents)); | 225 EXPECT_FALSE(service.IsTracked(contents)); |
226 EXPECT_EQ(NULL, service.GetAppBackgroundContents(ASCIIToUTF16("appid"))); | 226 EXPECT_EQ(NULL, service.GetAppBackgroundContents(ASCIIToUTF16("appid"))); |
227 EXPECT_EQ(1U, GetPrefs(&profile)->size()); | 227 EXPECT_EQ(1U, GetPrefs(&profile)->size()); |
228 EXPECT_EQ(url2.spec(), GetPrefURLForApp(&profile, contents2->appid())); | 228 EXPECT_EQ(url2.spec(), GetPrefURLForApp(&profile, contents2->appid())); |
229 } | 229 } |
OLD | NEW |