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