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

Side by Side Diff: chrome/browser/ui/app_list/app_list_controller_browsertest.cc

Issue 219383006: Never create an app list for an incognito profile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix cros Created 6 years, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/path_service.h" 5 #include "base/path_service.h"
6 #include "base/run_loop.h" 6 #include "base/run_loop.h"
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "chrome/browser/extensions/extension_browsertest.h" 8 #include "chrome/browser/extensions/extension_browsertest.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/ui/app_list/app_list_controller_delegate.h" 10 #include "chrome/browser/ui/app_list/app_list_controller_delegate.h"
(...skipping 26 matching lines...) Expand all
37 browser()->profile()->GetOffTheRecordProfile(), desktop)); 37 browser()->profile()->GetOffTheRecordProfile(), desktop));
38 38
39 controller->CreateNewWindow(browser()->profile(), false); 39 controller->CreateNewWindow(browser()->profile(), false);
40 EXPECT_EQ(2U, chrome::GetBrowserCount(browser()->profile(), desktop)); 40 EXPECT_EQ(2U, chrome::GetBrowserCount(browser()->profile(), desktop));
41 41
42 controller->CreateNewWindow(browser()->profile(), true); 42 controller->CreateNewWindow(browser()->profile(), true);
43 EXPECT_EQ(1U, chrome::GetBrowserCount( 43 EXPECT_EQ(1U, chrome::GetBrowserCount(
44 browser()->profile()->GetOffTheRecordProfile(), desktop)); 44 browser()->profile()->GetOffTheRecordProfile(), desktop));
45 } 45 }
46 46
47 // Test creating the app list for an incognito version of the current profile.
48 IN_PROC_BROWSER_TEST_F(AppListControllerBrowserTest, RegularThenIncognito) {
49 AppListService* service = test::GetAppListService();
50 // On Ash, the app list always has a profile.
51 if (chrome::GetActiveDesktop() == chrome::HOST_DESKTOP_TYPE_ASH)
52 EXPECT_TRUE(service->GetCurrentAppListProfile());
53 else
54 EXPECT_FALSE(service->GetCurrentAppListProfile());
55
56 service->ShowForProfile(browser()->profile());
57 EXPECT_EQ(browser()->profile(), service->GetCurrentAppListProfile());
58
59 AppListControllerDelegate* controller = service->GetControllerDelegate();
60 service->ShowForProfile(browser()->profile()->GetOffTheRecordProfile());
61
62 // Should be showing the same profile.
63 EXPECT_EQ(browser()->profile(), service->GetCurrentAppListProfile());
64
65 // Should not have been reconstructed.
66 EXPECT_EQ(controller, service->GetControllerDelegate());
67
68 // Same checks for CreateForProfile().
69 service->CreateForProfile(browser()->profile()->GetOffTheRecordProfile());
70 EXPECT_EQ(browser()->profile(), service->GetCurrentAppListProfile());
71 EXPECT_EQ(controller, service->GetControllerDelegate());
72 }
73
74 // Test creating the initial app list for incognito profile.
75 IN_PROC_BROWSER_TEST_F(AppListControllerBrowserTest, Incognito) {
76 AppListService* service = test::GetAppListService();
77 if (chrome::GetActiveDesktop() == chrome::HOST_DESKTOP_TYPE_ASH)
78 EXPECT_TRUE(service->GetCurrentAppListProfile());
79 else
80 EXPECT_FALSE(service->GetCurrentAppListProfile());
81
82 service->ShowForProfile(browser()->profile()->GetOffTheRecordProfile());
83 // Initial load should have picked the non-incongito profile.
84 EXPECT_EQ(browser()->profile(), service->GetCurrentAppListProfile());
85 }
86
47 // Browser Test for AppListController that observes search result changes. 87 // Browser Test for AppListController that observes search result changes.
48 class AppListControllerSearchResultsBrowserTest 88 class AppListControllerSearchResultsBrowserTest
49 : public ExtensionBrowserTest, 89 : public ExtensionBrowserTest,
50 public app_list::SearchResultObserver, 90 public app_list::SearchResultObserver,
51 public ui::ListModelObserver { 91 public ui::ListModelObserver {
52 public: 92 public:
53 AppListControllerSearchResultsBrowserTest() 93 AppListControllerSearchResultsBrowserTest()
54 : observed_result_(NULL), 94 : observed_result_(NULL),
55 item_uninstall_count_(0), 95 item_uninstall_count_(0),
56 observed_results_list_(NULL) {} 96 observed_results_list_(NULL) {}
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 EXPECT_EQ(1, item_uninstall_count_); 196 EXPECT_EQ(1, item_uninstall_count_);
157 197
158 // Results should not be immediately refreshed. When they are, the item should 198 // Results should not be immediately refreshed. When they are, the item should
159 // be removed from the model. 199 // be removed from the model.
160 EXPECT_TRUE(observed_result_); 200 EXPECT_TRUE(observed_result_);
161 base::RunLoop().RunUntilIdle(); 201 base::RunLoop().RunUntilIdle();
162 EXPECT_FALSE(observed_result_); 202 EXPECT_FALSE(observed_result_);
163 StopWatchingResults(); 203 StopWatchingResults();
164 service->DismissAppList(); 204 service->DismissAppList();
165 } 205 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/app_list/app_list_service_mac.mm » ('j') | chrome/browser/ui/app_list/app_list_shower.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698