Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6191)

Unified Diff: chrome/browser/themes/theme_service_unittest.cc

Issue 2919953002: Revert of Unpack theme data from extensions off of UI thread. (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/themes/theme_service_unittest.cc
diff --git a/chrome/browser/themes/theme_service_unittest.cc b/chrome/browser/themes/theme_service_unittest.cc
index 83114e61641f459faffb7333e683269eaf083896..7f6807eea75c2b1002e96510411ddafdc53fc771 100644
--- a/chrome/browser/themes/theme_service_unittest.cc
+++ b/chrome/browser/themes/theme_service_unittest.cc
@@ -10,7 +10,6 @@
#include "base/path_service.h"
#include "base/run_loop.h"
#include "base/strings/stringprintf.h"
-#include "base/test/scoped_task_environment.h"
#include "build/build_config.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/extensions/extension_service.h"
@@ -78,7 +77,8 @@
installer->Load(temp_dir);
std::string extension_id = observer.WaitForExtensionLoaded()->id();
- WaitForThemeInstall();
+ // Let the ThemeService finish creating the theme pack.
+ base::RunLoop().RunUntilIdle();
return extension_id;
}
@@ -111,14 +111,6 @@
return theme_service->get_theme_supplier();
}
- void WaitForThemeInstall() {
- content::WindowedNotificationObserver theme_change_observer(
- chrome::NOTIFICATION_BROWSER_THEME_CHANGED,
- content::Source<ThemeService>(
- ThemeServiceFactory::GetForProfile(profile())));
- theme_change_observer.Wait();
- }
-
// Alpha blends a non-opaque foreground color against an opaque background.
// This is not the same as color_utils::AlphaBlend() since it gets the opacity
// from the foreground color and then does not blend the two colors' alpha
@@ -171,6 +163,8 @@
ThemeService* theme_service =
ThemeServiceFactory::GetForProfile(profile_.get());
theme_service->UseDefaultTheme();
+ // Let the ThemeService uninstall unused themes.
+ base::RunLoop().RunUntilIdle();
base::ScopedTempDir temp_dir1;
ASSERT_TRUE(temp_dir1.CreateUniqueTempDir());
@@ -194,19 +188,19 @@
// 2) Enabling a disabled theme extension should swap the current theme.
service_->EnableExtension(extension1_id);
- WaitForThemeInstall();
+ base::RunLoop().RunUntilIdle();
EXPECT_EQ(extension1_id, theme_service->GetThemeID());
EXPECT_TRUE(service_->IsExtensionEnabled(extension1_id));
EXPECT_TRUE(registry_->GetExtensionById(extension2_id,
ExtensionRegistry::DISABLED));
- // 3) Using RevertToTheme() with a disabled theme should enable and set the
+ // 3) Using SetTheme() with a disabled theme should enable and set the
// theme. This is the case when the user reverts to the previous theme
// via an infobar.
const extensions::Extension* extension2 =
service_->GetInstalledExtension(extension2_id);
- theme_service->RevertToTheme(extension2);
- WaitForThemeInstall();
+ theme_service->SetTheme(extension2);
+ base::RunLoop().RunUntilIdle();
EXPECT_EQ(extension2_id, theme_service->GetThemeID());
EXPECT_TRUE(service_->IsExtensionEnabled(extension2_id));
EXPECT_TRUE(registry_->GetExtensionById(extension1_id,
@@ -346,21 +340,18 @@
// Show an infobar.
theme_service->OnInfobarDisplayed();
- // Install another theme. The first extension shouldn't be uninstalled yet as
- // it should be possible to revert to it. Emulate the infobar destroying
- // itself as a result of the NOTIFICATION_BROWSER_THEME_CHANGED notification.
+ // Install another theme. Emulate the infobar destroying itself (and
+ // causing unused themes to be uninstalled) as a result of the
+ // NOTIFICATION_BROWSER_THEME_CHANGED notification.
{
InfobarDestroyerOnThemeChange destroyer(profile_.get());
const std::string& extension2_id = LoadUnpackedThemeAt(temp_dir2.GetPath());
- EXPECT_EQ(extension2_id, theme_service->GetThemeID());
- }
-
- auto* extension1 = service_->GetInstalledExtension(extension1_id);
- ASSERT_TRUE(extension1);
+ ASSERT_EQ(extension2_id, theme_service->GetThemeID());
+ ASSERT_FALSE(service_->GetInstalledExtension(extension1_id));
+ }
// Check that it is possible to reinstall extension1.
- ThemeServiceFactory::GetForProfile(profile_.get())->RevertToTheme(extension1);
- WaitForThemeInstall();
+ ASSERT_EQ(extension1_id, LoadUnpackedThemeAt(temp_dir1.GetPath()));
EXPECT_EQ(extension1_id, theme_service->GetThemeID());
}
« no previous file with comments | « chrome/browser/themes/theme_service_browsertest.cc ('k') | chrome/browser/ui/extensions/extension_install_ui_default.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698