#include "ui/base/models/menu_model.h"
#if defined(OS_CHROMEOS)
-#include "apps/app_window_contents.h"
-#include "apps/app_window_registry.h"
-#include "apps/ui/native_app_window.h"
#include "ash/test/test_session_state_delegate.h"
#include "ash/test/test_shell_delegate.h"
+#include "chrome/browser/apps/scoped_keep_alive.h"
#include "chrome/browser/chromeos/login/users/fake_user_manager.h"
#include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h"
#include "chrome/browser/ui/apps/chrome_app_delegate.h"
#include "chrome/test/base/testing_profile_manager.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/test/test_utils.h"
+#include "extensions/browser/app_window/app_window_contents.h"
+#include "extensions/browser/app_window/app_window_registry.h"
+#include "extensions/browser/app_window/native_app_window.h"
#include "ui/aura/window.h"
#endif
const char* kGmailLaunchURL = "https://mail.google.com/mail/ca";
#if defined(OS_CHROMEOS)
-// As defined in /chromeos/dbus/cryptohome_client.cc.
-const char kUserIdHashSuffix[] = "-hash";
-
// An extension prefix.
const char kCrxAppPrefix[] = "_crx_";
#endif
class V2App {
public:
V2App(Profile* profile, const extensions::Extension* extension) {
- window_ = new apps::AppWindow(profile, new ChromeAppDelegate(), extension);
- apps::AppWindow::CreateParams params = apps::AppWindow::CreateParams();
- window_->Init(
- GURL(std::string()), new apps::AppWindowContentsImpl(window_), params);
+ window_ = new extensions::AppWindow(
+ profile,
+ new ChromeAppDelegate(make_scoped_ptr(new ScopedKeepAlive)),
+ extension);
+ extensions::AppWindow::CreateParams params =
+ extensions::AppWindow::CreateParams();
+ window_->Init(GURL(std::string()),
+ new extensions::AppWindowContentsImpl(window_), params);
}
virtual ~V2App() {
destroyed_watcher.Wait();
}
- apps::AppWindow* window() { return window_; }
+ extensions::AppWindow* window() { return window_; }
private:
// The app window which represents the application. Note that the window
// deletes itself asynchronously after window_->GetBaseWindow()->Close() gets
// called.
- apps::AppWindow* window_;
+ extensions::AppWindow* window_;
DISALLOW_COPY_AND_ASSIGN(V2App);
};
session_delegate()->AddUser(email_string);
GetFakeUserManager()->AddUser(email_string);
- GetFakeUserManager()->UserLoggedIn(
- email_string,
- email_string + kUserIdHashSuffix,
- false);
-
- std::string profile_name =
- chrome::kProfileDirPrefix + email_string + kUserIdHashSuffix;
- TestingProfile* profile = profile_manager()->CreateTestingProfile(
- profile_name,
- scoped_ptr<PrefServiceSyncable>(),
- ASCIIToUTF16(email_string), 0, std::string(),
- TestingProfile::TestingFactories());
- profile->set_profile_name(email_string);
+ GetFakeUserManager()->LoginUser(email_string);
+
+ TestingProfile* profile =
+ profile_manager()->CreateTestingProfile(email_string);
EXPECT_TRUE(profile);
+
// Remember the profile name so that we can destroy it upon destruction.
- created_profiles_[profile] = profile_name;
+ created_profiles_[profile] = email_string;
if (chrome::MultiUserWindowManager::GetInstance())
chrome::MultiUserWindowManager::GetInstance()->AddUser(profile);
if (launcher_controller_)
EXPECT_EQ(2, model_->item_count());
// Add a v2 app.
- V2App v2_app(profile(), extension1_);
+ V2App v2_app(profile(), extension1_.get());
EXPECT_EQ(3, model_->item_count());
// After switching users the item should go away.
// Add the v2 app to the inactive user and check that no item was added to
// the launcher.
{
- V2App v2_app(profile(), extension1_);
+ V2App v2_app(profile(), extension1_.get());
EXPECT_EQ(2, model_->item_count());
// Switch to the primary user and check that the item is shown.
// A v2 app for user #1 should be shown first and get hidden when switching to
// desktop #2.
- V2App v2_app_1(profile1, extension1_);
+ V2App v2_app_1(profile1, extension1_.get());
EXPECT_TRUE(v2_app_1.window()->GetNativeWindow()->IsVisible());
SwitchActiveUser(profile2->GetProfileName());
EXPECT_FALSE(v2_app_1.window()->GetNativeWindow()->IsVisible());
// Add a v2 app for user #1 while on desktop #2 should not be shown.
- V2App v2_app_2(profile1, extension1_);
+ V2App v2_app_2(profile1, extension1_.get());
EXPECT_FALSE(v2_app_1.window()->GetNativeWindow()->IsVisible());
EXPECT_FALSE(v2_app_2.window()->GetNativeWindow()->IsVisible());
// Creating a new application for user #1 on desktop #2 should teleport it
// there automatically.
- V2App v2_app_3(profile1, extension1_);
+ V2App v2_app_3(profile1, extension1_.get());
EXPECT_TRUE(v2_app_1.window()->GetNativeWindow()->IsVisible());
EXPECT_FALSE(v2_app_2.window()->GetNativeWindow()->IsVisible());
EXPECT_TRUE(v2_app_3.window()->GetNativeWindow()->IsVisible());
// Switching back to desktop#1 and creating an app for user #1 should move
// the app on desktop #1.
SwitchActiveUser(profile1->GetProfileName());
- V2App v2_app_4(profile1, extension1_);
+ V2App v2_app_4(profile1, extension1_.get());
EXPECT_FALSE(v2_app_1.window()->GetNativeWindow()->IsVisible());
EXPECT_TRUE(v2_app_2.window()->GetNativeWindow()->IsVisible());
EXPECT_FALSE(v2_app_3.window()->GetNativeWindow()->IsVisible());
// Switching to desktop #3 and create an app for user #1 there should land on
// his own desktop (#1).
SwitchActiveUser(profile3->GetProfileName());
- V2App v2_app_5(profile1, extension1_);
+ V2App v2_app_5(profile1, extension1_.get());
EXPECT_FALSE(v2_app_5.window()->GetNativeWindow()->IsVisible());
SwitchActiveUser(profile1->GetProfileName());
EXPECT_TRUE(v2_app_5.window()->GetNativeWindow()->IsVisible());
// teleport there automatically.
SwitchActiveUser(profile2->GetProfileName());
v2_app_1.window()->Hide();
- V2App v2_app_6(profile1, extension1_);
+ V2App v2_app_6(profile1, extension1_.get());
EXPECT_FALSE(v2_app_1.window()->GetNativeWindow()->IsVisible());
EXPECT_FALSE(v2_app_2.window()->GetNativeWindow()->IsVisible());
EXPECT_TRUE(v2_app_6.window()->GetNativeWindow()->IsVisible());
SwitchActiveUser(profile()->GetProfileName());
EXPECT_EQ(2, model_->item_count());
- V2App v2_app_1(profile(), extension1_);
+ V2App v2_app_1(profile(), extension1_.get());
EXPECT_EQ(3, model_->item_count());
{
// Hide and show the app.
v2_app_1.window()->Hide();
EXPECT_EQ(2, model_->item_count());
- v2_app_1.window()->Show(apps::AppWindow::SHOW_ACTIVE);
+ v2_app_1.window()->Show(extensions::AppWindow::SHOW_ACTIVE);
EXPECT_EQ(3, model_->item_count());
}
{
v2_app_1.window()->Hide();
EXPECT_EQ(2, model_->item_count());
- v2_app_1.window()->Show(apps::AppWindow::SHOW_ACTIVE);
+ v2_app_1.window()->Show(extensions::AppWindow::SHOW_ACTIVE);
EXPECT_EQ(2, model_->item_count());
SwitchActiveUser(profile()->GetProfileName());
SwitchActiveUser(profile()->GetProfileName());
EXPECT_EQ(2, model_->item_count());
- v2_app_1.window()->Show(apps::AppWindow::SHOW_ACTIVE);
+ v2_app_1.window()->Show(extensions::AppWindow::SHOW_ACTIVE);
EXPECT_EQ(3, model_->item_count());
}
{
// Create a second app, hide and show it and then hide both apps.
- V2App v2_app_2(profile(), extension1_);
+ V2App v2_app_2(profile(), extension1_.get());
EXPECT_EQ(3, model_->item_count());
v2_app_2.window()->Hide();
EXPECT_EQ(3, model_->item_count());
- v2_app_2.window()->Show(apps::AppWindow::SHOW_ACTIVE);
+ v2_app_2.window()->Show(extensions::AppWindow::SHOW_ACTIVE);
EXPECT_EQ(3, model_->item_count());
v2_app_1.window()->Hide();