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

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: rebase Created 6 years, 1 month 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
« no previous file with comments | « no previous file | chrome/browser/ui/app_list/app_list_service_mac.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 set of tests using ShowForAppInstall, which the webstore uses and was
69 // traditionally where issues with incognito-mode app launchers started. Pass
70 // true for start_discovery_tracking to emulate what the webstore does on the
71 // first app install, to cover AppListServiceImpl::CreateForProfile().
72 service->ShowForAppInstall(
73 browser()->profile()->GetOffTheRecordProfile(), "", true);
74 EXPECT_EQ(browser()->profile(), service->GetCurrentAppListProfile());
75 EXPECT_EQ(controller, service->GetControllerDelegate());
76 }
77
78 // Test creating the initial app list for incognito profile.
79 IN_PROC_BROWSER_TEST_F(AppListControllerBrowserTest, Incognito) {
80 AppListService* service = test::GetAppListService();
81 if (chrome::GetActiveDesktop() == chrome::HOST_DESKTOP_TYPE_ASH)
82 EXPECT_TRUE(service->GetCurrentAppListProfile());
83 else
84 EXPECT_FALSE(service->GetCurrentAppListProfile());
85
86 service->ShowForProfile(browser()->profile()->GetOffTheRecordProfile());
87 // Initial load should have picked the non-incongito profile.
88 EXPECT_EQ(browser()->profile(), service->GetCurrentAppListProfile());
89 }
90
47 // Browser Test for AppListController that observes search result changes. 91 // Browser Test for AppListController that observes search result changes.
48 class AppListControllerSearchResultsBrowserTest 92 class AppListControllerSearchResultsBrowserTest
49 : public ExtensionBrowserTest, 93 : public ExtensionBrowserTest,
50 public app_list::SearchResultObserver, 94 public app_list::SearchResultObserver,
51 public ui::ListModelObserver { 95 public ui::ListModelObserver {
52 public: 96 public:
53 AppListControllerSearchResultsBrowserTest() 97 AppListControllerSearchResultsBrowserTest()
54 : observed_result_(NULL), 98 : observed_result_(NULL),
55 item_uninstall_count_(0), 99 item_uninstall_count_(0),
56 observed_results_list_(NULL) {} 100 observed_results_list_(NULL) {}
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 EXPECT_EQ(1, item_uninstall_count_); 206 EXPECT_EQ(1, item_uninstall_count_);
163 207
164 // Results should not be immediately refreshed. When they are, the item should 208 // Results should not be immediately refreshed. When they are, the item should
165 // be removed from the model. 209 // be removed from the model.
166 EXPECT_TRUE(observed_result_); 210 EXPECT_TRUE(observed_result_);
167 base::RunLoop().RunUntilIdle(); 211 base::RunLoop().RunUntilIdle();
168 EXPECT_FALSE(observed_result_); 212 EXPECT_FALSE(observed_result_);
169 StopWatchingResults(); 213 StopWatchingResults();
170 service->DismissAppList(); 214 service->DismissAppList();
171 } 215 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/app_list/app_list_service_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698