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

Side by Side Diff: chrome/browser/apps/custom_launcher_page_browsertest_views.cc

Issue 1257603003: Revert of Add ExecuteJavaScriptForTest and make all tests use it (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <string> 5 #include <string>
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/apps/app_browsertest_util.h" 10 #include "chrome/browser/apps/app_browsertest_util.h"
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 GetAppListView()->app_list_main_view()->contents_view(); 106 GetAppListView()->app_list_main_view()->contents_view();
107 views::WebView* custom_page_view = static_cast<views::WebView*>( 107 views::WebView* custom_page_view = static_cast<views::WebView*>(
108 contents_view->custom_page_view()->custom_launcher_page_contents()); 108 contents_view->custom_page_view()->custom_launcher_page_contents());
109 content::RenderFrameHost* custom_page_frame = 109 content::RenderFrameHost* custom_page_frame =
110 custom_page_view->GetWebContents()->GetMainFrame(); 110 custom_page_view->GetWebContents()->GetMainFrame();
111 111
112 const char* test_message = 112 const char* test_message =
113 enabled ? "launcherPageEnabled" : "launcherPageDisabled"; 113 enabled ? "launcherPageEnabled" : "launcherPageDisabled";
114 114
115 ExtensionTestMessageListener listener(test_message, false); 115 ExtensionTestMessageListener listener(test_message, false);
116 custom_page_frame->ExecuteJavaScriptForTests( 116 custom_page_frame->ExecuteJavaScript(enabled ? kLauncherPageEnableScript
117 enabled ? kLauncherPageEnableScript : kLauncherPageDisableScript); 117 : kLauncherPageDisableScript);
118 listener.WaitUntilSatisfied(); 118 listener.WaitUntilSatisfied();
119 } 119 }
120 120
121 private: 121 private:
122 DISALLOW_COPY_AND_ASSIGN(CustomLauncherPageBrowserTest); 122 DISALLOW_COPY_AND_ASSIGN(CustomLauncherPageBrowserTest);
123 }; 123 };
124 124
125 IN_PROC_BROWSER_TEST_F(CustomLauncherPageBrowserTest, 125 IN_PROC_BROWSER_TEST_F(CustomLauncherPageBrowserTest,
126 OpenLauncherAndSwitchToCustomPage) { 126 OpenLauncherAndSwitchToCustomPage) {
127 LoadAndLaunchPlatformApp(kCustomLauncherPagePath, "Launched"); 127 LoadAndLaunchPlatformApp(kCustomLauncherPagePath, "Launched");
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 content::RenderFrameHost* custom_page_frame = 332 content::RenderFrameHost* custom_page_frame =
333 custom_page_view->GetWebContents()->GetMainFrame(); 333 custom_page_view->GetWebContents()->GetMainFrame();
334 334
335 ASSERT_TRUE( 335 ASSERT_TRUE(
336 contents_view->IsStateActive(app_list::AppListModel::STATE_START)); 336 contents_view->IsStateActive(app_list::AppListModel::STATE_START));
337 337
338 // Ensure launcherPage.show() will switch the page to the custom launcher page 338 // Ensure launcherPage.show() will switch the page to the custom launcher page
339 // if the app launcher is already showing. 339 // if the app launcher is already showing.
340 { 340 {
341 ExtensionTestMessageListener listener("onPageProgressAt1", false); 341 ExtensionTestMessageListener listener("onPageProgressAt1", false);
342 custom_page_frame->ExecuteJavaScriptForTests(kLauncherPageShowScript); 342 custom_page_frame->ExecuteJavaScript(kLauncherPageShowScript);
343 343
344 listener.WaitUntilSatisfied(); 344 listener.WaitUntilSatisfied();
345 EXPECT_TRUE(contents_view->IsStateActive( 345 EXPECT_TRUE(contents_view->IsStateActive(
346 app_list::AppListModel::STATE_CUSTOM_LAUNCHER_PAGE)); 346 app_list::AppListModel::STATE_CUSTOM_LAUNCHER_PAGE));
347 } 347 }
348 348
349 // Ensure launcherPage.show() will show the app list if it's hidden. 349 // Ensure launcherPage.show() will show the app list if it's hidden.
350 { 350 {
351 // Close the app list immediately. 351 // Close the app list immediately.
352 app_list_view->Close(); 352 app_list_view->Close();
353 app_list_view->GetWidget()->Close(); 353 app_list_view->GetWidget()->Close();
354 354
355 ExtensionTestMessageListener listener("onPageProgressAt1", false); 355 ExtensionTestMessageListener listener("onPageProgressAt1", false);
356 custom_page_frame->ExecuteJavaScriptForTests(kLauncherPageShowScript); 356 custom_page_frame->ExecuteJavaScript(kLauncherPageShowScript);
357 357
358 listener.WaitUntilSatisfied(); 358 listener.WaitUntilSatisfied();
359 359
360 // The app list view will have changed on ChromeOS. 360 // The app list view will have changed on ChromeOS.
361 app_list_view = GetAppListView(); 361 app_list_view = GetAppListView();
362 contents_view = app_list_view->app_list_main_view()->contents_view(); 362 contents_view = app_list_view->app_list_main_view()->contents_view();
363 EXPECT_TRUE(contents_view->IsStateActive( 363 EXPECT_TRUE(contents_view->IsStateActive(
364 app_list::AppListModel::STATE_CUSTOM_LAUNCHER_PAGE)); 364 app_list::AppListModel::STATE_CUSTOM_LAUNCHER_PAGE));
365 } 365 }
366 366
367 // Ensure launcherPage.hide() hides the launcher page when it's showing. 367 // Ensure launcherPage.hide() hides the launcher page when it's showing.
368 { 368 {
369 ExtensionTestMessageListener listener("onPageProgressAt0", false); 369 ExtensionTestMessageListener listener("onPageProgressAt0", false);
370 custom_page_frame->ExecuteJavaScriptForTests(kLauncherPageHideScript); 370 custom_page_frame->ExecuteJavaScript(kLauncherPageHideScript);
371 371
372 listener.WaitUntilSatisfied(); 372 listener.WaitUntilSatisfied();
373 373
374 EXPECT_TRUE( 374 EXPECT_TRUE(
375 contents_view->IsStateActive(app_list::AppListModel::STATE_START)); 375 contents_view->IsStateActive(app_list::AppListModel::STATE_START));
376 } 376 }
377 377
378 // Nothing should happen if hide() is called from the apps page. 378 // Nothing should happen if hide() is called from the apps page.
379 { 379 {
380 contents_view->SetActiveState(app_list::AppListModel::STATE_APPS, false); 380 contents_view->SetActiveState(app_list::AppListModel::STATE_APPS, false);
381 381
382 ExtensionTestMessageListener listener("launcherPageHidden", false); 382 ExtensionTestMessageListener listener("launcherPageHidden", false);
383 custom_page_frame->ExecuteJavaScriptForTests(kLauncherPageHideScript); 383 custom_page_frame->ExecuteJavaScript(kLauncherPageHideScript);
384 listener.WaitUntilSatisfied(); 384 listener.WaitUntilSatisfied();
385 385
386 EXPECT_TRUE( 386 EXPECT_TRUE(
387 contents_view->IsStateActive(app_list::AppListModel::STATE_APPS)); 387 contents_view->IsStateActive(app_list::AppListModel::STATE_APPS));
388 } 388 }
389 } 389 }
390 390
391 IN_PROC_BROWSER_TEST_F(CustomLauncherPageBrowserTest, LauncherPageSetEnabled) { 391 IN_PROC_BROWSER_TEST_F(CustomLauncherPageBrowserTest, LauncherPageSetEnabled) {
392 LoadAndLaunchPlatformApp(kCustomLauncherPagePath, "Launched"); 392 LoadAndLaunchPlatformApp(kCustomLauncherPagePath, "Launched");
393 app_list::AppListView* app_list_view = GetAppListView(); 393 app_list::AppListView* app_list_view = GetAppListView();
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 // And in reverse. 448 // And in reverse.
449 EXPECT_EQ( 449 EXPECT_EQ(
450 search_box_textfield, 450 search_box_textfield,
451 app_list_view->GetFocusManager()->GetNextFocusableView( 451 app_list_view->GetFocusManager()->GetNextFocusableView(
452 custom_page_webview, custom_page_webview->GetWidget(), true, false)); 452 custom_page_webview, custom_page_webview->GetWidget(), true, false));
453 EXPECT_EQ(custom_page_webview, 453 EXPECT_EQ(custom_page_webview,
454 app_list_view->GetFocusManager()->GetNextFocusableView( 454 app_list_view->GetFocusManager()->GetNextFocusableView(
455 search_box_textfield, search_box_textfield->GetWidget(), true, 455 search_box_textfield, search_box_textfield->GetWidget(), true,
456 false)); 456 false));
457 } 457 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698