OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/logging.h" | 5 #include "base/logging.h" |
| 6 #include "chrome/browser/browser_process.h" |
6 #include "chrome/browser/extensions/apps_promo.h" | 7 #include "chrome/browser/extensions/apps_promo.h" |
7 #include "chrome/browser/prefs/browser_prefs.h" | 8 #include "chrome/browser/prefs/browser_prefs.h" |
8 #include "chrome/browser/ui/webui/ntp/shown_sections_handler.h" | 9 #include "chrome/browser/ui/webui/ntp/shown_sections_handler.h" |
9 #include "chrome/common/extensions/extension.h" | 10 #include "chrome/common/extensions/extension.h" |
10 #include "chrome/common/pref_names.h" | 11 #include "chrome/common/pref_names.h" |
11 #include "chrome/test/base/testing_browser_process_test.h" | 12 #include "chrome/test/base/testing_browser_process.h" |
12 #include "chrome/test/base/testing_pref_service.h" | 13 #include "chrome/test/base/testing_pref_service.h" |
13 #include "googleurl/src/gurl.h" | 14 #include "googleurl/src/gurl.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
15 | 16 |
16 namespace { | 17 namespace { |
17 | 18 |
18 const char kPromoId[] = "23123123"; | 19 const char kPromoId[] = "23123123"; |
19 const char kPromoHeader[] = "Get great apps!"; | 20 const char kPromoHeader[] = "Get great apps!"; |
20 const char kPromoButton[] = "Click for apps!"; | 21 const char kPromoButton[] = "Click for apps!"; |
21 const char kPromoLink[] = "http://apps.com"; | 22 const char kPromoLink[] = "http://apps.com"; |
(...skipping 13 matching lines...) Expand all Loading... |
35 // Hiding the promo places the apps section in menu mode and maximizes the | 36 // Hiding the promo places the apps section in menu mode and maximizes the |
36 // most visited section. | 37 // most visited section. |
37 EXPECT_TRUE((ShownSectionsHandler::GetShownSections(prefs) & | 38 EXPECT_TRUE((ShownSectionsHandler::GetShownSections(prefs) & |
38 APPS) == 0); | 39 APPS) == 0); |
39 EXPECT_TRUE((ShownSectionsHandler::GetShownSections(prefs) & | 40 EXPECT_TRUE((ShownSectionsHandler::GetShownSections(prefs) & |
40 (MENU_APPS | THUMB)) != 0); | 41 (MENU_APPS | THUMB)) != 0); |
41 } | 42 } |
42 | 43 |
43 } // namespace | 44 } // namespace |
44 | 45 |
45 class ExtensionAppsPromo : public TestingBrowserProcessTest { | 46 class ExtensionAppsPromo : public testing::Test { |
46 public: | 47 public: |
47 TestingPrefService* prefs() { return &prefs_; } | 48 TestingPrefService* prefs() { return &prefs_; } |
48 AppsPromo* apps_promo() { return &apps_promo_; } | 49 AppsPromo* apps_promo() { return &apps_promo_; } |
49 | 50 |
50 protected: | 51 protected: |
51 explicit ExtensionAppsPromo(); | 52 explicit ExtensionAppsPromo(); |
52 | 53 |
53 // testing::Test | 54 // testing::Test |
54 virtual void SetUp(); | 55 virtual void SetUp(); |
55 | 56 |
56 private: | 57 private: |
57 TestingPrefService prefs_; | 58 TestingPrefService prefs_; |
58 ScopedTestingLocalState local_state_; | 59 ScopedTestingLocalState local_state_; |
59 AppsPromo apps_promo_; | 60 AppsPromo apps_promo_; |
60 }; | 61 }; |
61 | 62 |
62 ExtensionAppsPromo::ExtensionAppsPromo() | 63 ExtensionAppsPromo::ExtensionAppsPromo() |
63 : local_state_(testing_browser_process_.get()), | 64 : local_state_(static_cast<TestingBrowserProcess*>(g_browser_process)), |
64 apps_promo_(&prefs_) { | 65 apps_promo_(&prefs_) { |
65 } | 66 } |
66 | 67 |
67 void ExtensionAppsPromo::SetUp() { | 68 void ExtensionAppsPromo::SetUp() { |
68 browser::RegisterUserPrefs(&prefs_); | 69 browser::RegisterUserPrefs(&prefs_); |
69 } | 70 } |
70 | 71 |
71 // TODO(dpolukhin): On Chrome OS all apps are installed via external extensions, | 72 // TODO(dpolukhin): On Chrome OS all apps are installed via external extensions, |
72 // and the web store promo is never shown. | 73 // and the web store promo is never shown. |
73 #if !defined(OS_CHROMEOS) | 74 #if !defined(OS_CHROMEOS) |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 EXPECT_TRUE(show_promo); | 329 EXPECT_TRUE(show_promo); |
329 | 330 |
330 // When the "hide" pref is true, the promo should NOT appear. | 331 // When the "hide" pref is true, the promo should NOT appear. |
331 prefs()->SetBoolean(prefs::kNTPHideWebStorePromo, true); | 332 prefs()->SetBoolean(prefs::kNTPHideWebStorePromo, true); |
332 show_promo = apps_promo()->ShouldShowPromo( | 333 show_promo = apps_promo()->ShouldShowPromo( |
333 apps_promo()->old_default_apps(), &just_expired); | 334 apps_promo()->old_default_apps(), &just_expired); |
334 EXPECT_FALSE(show_promo); | 335 EXPECT_FALSE(show_promo); |
335 } | 336 } |
336 | 337 |
337 #endif // OS_CHROMEOS | 338 #endif // OS_CHROMEOS |
OLD | NEW |