This source file includes following definitions.
- showed_background_app_installed_notification_for_test_
- DisplayAppInstalledNotification
- showed_background_app_installed_notification_for_test
- set_showed_background_app_installed_notification_for_test
- IN_PROC_BROWSER_TEST_F
#include "chrome/browser/background/background_mode_manager.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/extensions/extension_browsertest.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/test/base/ui_test_utils.h"
class TestBackgroundModeManager : public BackgroundModeManager {
public:
TestBackgroundModeManager(CommandLine* command_line,
ProfileInfoCache* profile_cache)
: BackgroundModeManager(command_line, profile_cache),
showed_background_app_installed_notification_for_test_(false) {}
virtual ~TestBackgroundModeManager() {}
virtual void DisplayAppInstalledNotification(
const extensions::Extension* extension) OVERRIDE {
showed_background_app_installed_notification_for_test_ = true;
}
bool showed_background_app_installed_notification_for_test() {
return showed_background_app_installed_notification_for_test_;
}
void set_showed_background_app_installed_notification_for_test(
bool showed) {
showed_background_app_installed_notification_for_test_ = showed;
}
private:
bool showed_background_app_installed_notification_for_test_;
FRIEND_TEST_ALL_PREFIXES(BackgroundAppBrowserTest,
ReloadBackgroundApp);
DISALLOW_COPY_AND_ASSIGN(TestBackgroundModeManager);
};
class BackgroundAppBrowserTest: public ExtensionBrowserTest {};
IN_PROC_BROWSER_TEST_F(BackgroundAppBrowserTest, ReloadBackgroundApp) {
scoped_ptr<BackgroundModeManager> test_background_mode_manager(
new TestBackgroundModeManager(
CommandLine::ForCurrentProcess(),
&(g_browser_process->profile_manager()->GetProfileInfoCache())));
g_browser_process->set_background_mode_manager_for_test(
test_background_mode_manager.Pass());
TestBackgroundModeManager* manager =
reinterpret_cast<TestBackgroundModeManager*>(
g_browser_process->background_mode_manager());
ASSERT_FALSE(
manager->showed_background_app_installed_notification_for_test());
const extensions::Extension* extension = LoadExtension(
test_data_dir_.AppendASCII("background_app"));
ASSERT_FALSE(extension == NULL);
manager->set_showed_background_app_installed_notification_for_test(false);
ReloadExtension(extension->id());
EXPECT_FALSE(
manager->showed_background_app_installed_notification_for_test());
}