OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "base/strings/string_util.h" | 5 #include "base/strings/string_util.h" |
6 #include "chrome/app/chrome_command_ids.h" | 6 #include "chrome/app/chrome_command_ids.h" |
7 #include "chrome/browser/chrome_notification_types.h" | 7 #include "chrome/browser/chrome_notification_types.h" |
8 #include "chrome/browser/extensions/extension_browsertest.h" | 8 #include "chrome/browser/extensions/extension_browsertest.h" |
9 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
10 #include "chrome/browser/extensions/extension_sorting.h" | 10 #include "chrome/browser/extensions/extension_sorting.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 ConfirmInfoBarDelegate* delegate = | 45 ConfirmInfoBarDelegate* delegate = |
46 infobar_service->infobar_at(0)->AsConfirmInfoBarDelegate(); | 46 infobar_service->infobar_at(0)->AsConfirmInfoBarDelegate(); |
47 ASSERT_TRUE(delegate); | 47 ASSERT_TRUE(delegate); |
48 delegate->Cancel(); | 48 delegate->Cancel(); |
49 ASSERT_EQ(0U, infobar_service->infobar_count()); | 49 ASSERT_EQ(0U, infobar_service->infobar_count()); |
50 } | 50 } |
51 | 51 |
52 // Install the given theme from the data dir and verify expected name. | 52 // Install the given theme from the data dir and verify expected name. |
53 void InstallThemeAndVerify(const char* theme_name, | 53 void InstallThemeAndVerify(const char* theme_name, |
54 const std::string& expected_name) { | 54 const std::string& expected_name) { |
| 55 // If there is already a theme installed, the current theme should be |
| 56 // disabled and the new one installed + enabled. |
| 57 int expected_change = GetTheme() ? 0 : 1; |
55 const base::FilePath theme_path = test_data_dir_.AppendASCII(theme_name); | 58 const base::FilePath theme_path = test_data_dir_.AppendASCII(theme_name); |
56 ASSERT_TRUE(InstallExtensionWithUIAutoConfirm(theme_path, 1, browser())); | 59 ASSERT_TRUE(InstallExtensionWithUIAutoConfirm(theme_path, expected_change, |
| 60 browser())); |
57 const Extension* theme = GetTheme(); | 61 const Extension* theme = GetTheme(); |
58 ASSERT_TRUE(theme); | 62 ASSERT_TRUE(theme); |
59 ASSERT_EQ(theme->name(), expected_name); | 63 ASSERT_EQ(theme->name(), expected_name); |
60 } | 64 } |
61 | 65 |
62 const Extension* GetTheme() const { | 66 const Extension* GetTheme() const { |
63 return ThemeServiceFactory::GetThemeForProfile(browser()->profile()); | 67 return ThemeServiceFactory::GetThemeForProfile(browser()->profile()); |
64 } | 68 } |
65 }; | 69 }; |
66 | 70 |
(...skipping 16 matching lines...) Expand all Loading... |
83 // Install theme once and undo to verify we go back to default theme. | 87 // Install theme once and undo to verify we go back to default theme. |
84 base::FilePath theme_crx = PackExtension(test_data_dir_.AppendASCII("theme")); | 88 base::FilePath theme_crx = PackExtension(test_data_dir_.AppendASCII("theme")); |
85 ASSERT_TRUE(InstallExtensionWithUIAutoConfirm(theme_crx, 1, browser())); | 89 ASSERT_TRUE(InstallExtensionWithUIAutoConfirm(theme_crx, 1, browser())); |
86 const Extension* theme = GetTheme(); | 90 const Extension* theme = GetTheme(); |
87 ASSERT_TRUE(theme); | 91 ASSERT_TRUE(theme); |
88 std::string theme_id = theme->id(); | 92 std::string theme_id = theme->id(); |
89 VerifyThemeInfoBarAndUndoInstall(); | 93 VerifyThemeInfoBarAndUndoInstall(); |
90 ASSERT_EQ(NULL, GetTheme()); | 94 ASSERT_EQ(NULL, GetTheme()); |
91 | 95 |
92 // Set the same theme twice and undo to verify we go back to default theme. | 96 // Set the same theme twice and undo to verify we go back to default theme. |
93 ASSERT_TRUE(InstallExtensionWithUIAutoConfirm(theme_crx, 1, browser())); | 97 ASSERT_TRUE(InstallExtensionWithUIAutoConfirm(theme_crx, 0, browser())); |
94 theme = GetTheme(); | 98 theme = GetTheme(); |
95 ASSERT_TRUE(theme); | 99 ASSERT_TRUE(theme); |
96 ASSERT_EQ(theme_id, theme->id()); | 100 ASSERT_EQ(theme_id, theme->id()); |
97 ASSERT_TRUE(InstallExtensionWithUIAutoConfirm(theme_crx, 0, browser())); | 101 ASSERT_TRUE(InstallExtensionWithUIAutoConfirm(theme_crx, 0, browser())); |
98 theme = GetTheme(); | 102 theme = GetTheme(); |
99 ASSERT_TRUE(theme); | 103 ASSERT_TRUE(theme); |
100 ASSERT_EQ(theme_id, theme->id()); | 104 ASSERT_EQ(theme_id, theme->id()); |
101 VerifyThemeInfoBarAndUndoInstall(); | 105 VerifyThemeInfoBarAndUndoInstall(); |
102 ASSERT_EQ(NULL, GetTheme()); | 106 ASSERT_EQ(NULL, GetTheme()); |
103 } | 107 } |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 std::string(), | 236 std::string(), |
233 extension_misc::kWebStoreAppId); | 237 extension_misc::kWebStoreAppId); |
234 EXPECT_EQ(app_id, last_reordered_extension_id_); | 238 EXPECT_EQ(app_id, last_reordered_extension_id_); |
235 | 239 |
236 // Now install the app. | 240 // Now install the app. |
237 const extensions::Extension* test_app = LoadExtension(app_dir); | 241 const extensions::Extension* test_app = LoadExtension(app_dir); |
238 ASSERT_TRUE(test_app); | 242 ASSERT_TRUE(test_app); |
239 EXPECT_TRUE(service->GetInstalledExtension(app_id)); | 243 EXPECT_TRUE(service->GetInstalledExtension(app_id)); |
240 EXPECT_EQ(app_id, test_app->id()); | 244 EXPECT_EQ(app_id, test_app->id()); |
241 } | 245 } |
OLD | NEW |