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

Side by Side Diff: chrome/browser/task_manager/task_manager_browsertest.cc

Issue 1956813002: [Part 1 of 6] Move MockWebContentsTaskManager into its own file. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add Show() / ShowInactive() coverage. Created 4 years, 7 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/task_manager/task_manager.h" 5 #include "chrome/browser/task_manager/task_manager.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 295
296 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticePanel) { 296 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticePanel) {
297 ASSERT_TRUE(LoadExtension( 297 ASSERT_TRUE(LoadExtension(
298 test_data_dir_.AppendASCII("good").AppendASCII("Extensions") 298 test_data_dir_.AppendASCII("good").AppendASCII("Extensions")
299 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") 299 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj")
300 .AppendASCII("1.0.0.0"))); 300 .AppendASCII("1.0.0.0")));
301 301
302 // Open a new panel to an extension url. 302 // Open a new panel to an extension url.
303 GURL url( 303 GURL url(
304 "chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/french_sentence.html"); 304 "chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/french_sentence.html");
305 Panel* panel = PanelManager::GetInstance()->CreatePanel( 305 Panel* docked_panel = PanelManager::GetInstance()->CreatePanel(
306 web_app::GenerateApplicationNameFromExtensionId( 306 web_app::GenerateApplicationNameFromExtensionId(
307 last_loaded_extension_id()), 307 last_loaded_extension_id()),
308 browser()->profile(), 308 browser()->profile(), url, nullptr, gfx::Rect(300, 400),
309 url,
310 nullptr,
311 gfx::Rect(300, 400),
312 PanelManager::CREATE_AS_DOCKED); 309 PanelManager::CREATE_AS_DOCKED);
310 docked_panel->Show();
313 311
314 // Make sure that a task manager model created after the panel shows the 312 // Make sure that a task manager model created after the panel shows the
315 // existence of the panel and the extension. 313 // existence of the panel and the extension.
316 ShowTaskManager(); 314 ShowTaskManager();
317 ASSERT_NO_FATAL_FAILURE( 315 ASSERT_NO_FATAL_FAILURE(
318 WaitForTaskManagerRows(1, MatchExtension("My extension 1"))); 316 WaitForTaskManagerRows(1, MatchExtension("My extension 1")));
319 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows( 317 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(
320 1, 318 1,
321 MatchExtension( 319 MatchExtension(
322 "chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/" 320 "chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/"
323 "french_sentence.html"))); 321 "french_sentence.html")));
324 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyExtension())); 322 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyExtension()));
325 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab())); 323 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab()));
326 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); 324 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab()));
327 325
328 // Close the panel and verify that we notice. 326 // Create a second, detached panel.
329 panel->Close(); 327 Panel* detached_panel = PanelManager::GetInstance()->CreatePanel(
328 web_app::GenerateApplicationNameFromExtensionId(
329 last_loaded_extension_id()),
330 browser()->profile(), url, nullptr, gfx::Rect(150, 150),
331 PanelManager::CREATE_AS_DETACHED);
332 detached_panel->ShowInactive();
333
334 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(
335 2, MatchExtension("chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/"
336 "french_sentence.html")));
337 ASSERT_NO_FATAL_FAILURE(
338 WaitForTaskManagerRows(1, MatchExtension("My extension 1")));
339 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(3, MatchAnyExtension()));
340
341 // Close the panels and verify that we notice.
342 docked_panel->Close();
343 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyExtension()));
344 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(
345 1, MatchExtension("chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/"
346 "french_sentence.html")));
347 ASSERT_NO_FATAL_FAILURE(
348 WaitForTaskManagerRows(1, MatchExtension("My extension 1")));
349
350 detached_panel->Close();
330 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyExtension())); 351 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyExtension()));
331 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows( 352 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(
332 0, 353 0,
333 MatchExtension( 354 MatchExtension(
334 "chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/" 355 "chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/"
335 "french_sentence.html"))); 356 "french_sentence.html")));
336 ASSERT_NO_FATAL_FAILURE( 357 ASSERT_NO_FATAL_FAILURE(
337 WaitForTaskManagerRows(1, MatchExtension("My extension 1"))); 358 WaitForTaskManagerRows(1, MatchExtension("My extension 1")));
338 } 359 }
339 360
(...skipping 17 matching lines...) Expand all
357 GURL url( 378 GURL url(
358 "chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/french_sentence.html"); 379 "chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/french_sentence.html");
359 Panel* panel = PanelManager::GetInstance()->CreatePanel( 380 Panel* panel = PanelManager::GetInstance()->CreatePanel(
360 web_app::GenerateApplicationNameFromExtensionId( 381 web_app::GenerateApplicationNameFromExtensionId(
361 last_loaded_extension_id()), 382 last_loaded_extension_id()),
362 browser()->profile(), 383 browser()->profile(),
363 url, 384 url,
364 nullptr, 385 nullptr,
365 gfx::Rect(300, 400), 386 gfx::Rect(300, 400),
366 PanelManager::CREATE_AS_DOCKED); 387 PanelManager::CREATE_AS_DOCKED);
388 panel->ShowInactive();
389
367 ASSERT_NO_FATAL_FAILURE( 390 ASSERT_NO_FATAL_FAILURE(
368 WaitForTaskManagerRows(1, MatchExtension("My extension 1"))); 391 WaitForTaskManagerRows(1, MatchExtension("My extension 1")));
369 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows( 392 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(
370 1, 393 1,
371 MatchExtension( 394 MatchExtension(
372 "chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/" 395 "chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/"
373 "french_sentence.html"))); 396 "french_sentence.html")));
374 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyExtension())); 397 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyExtension()));
375 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab())); 398 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab()));
376 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); 399 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab()));
(...skipping 20 matching lines...) Expand all
397 ShowTaskManager(); 420 ShowTaskManager();
398 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("good") 421 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("good")
399 .AppendASCII("Extensions") 422 .AppendASCII("Extensions")
400 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") 423 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj")
401 .AppendASCII("1.0.0.0"))); 424 .AppendASCII("1.0.0.0")));
402 425
403 // Open a new panel to an extension url. 426 // Open a new panel to an extension url.
404 GURL url( 427 GURL url(
405 "chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/" 428 "chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/"
406 "french_sentence.html"); 429 "french_sentence.html");
407 PanelManager::GetInstance()->CreatePanel( 430 Panel* panel = PanelManager::GetInstance()->CreatePanel(
408 web_app::GenerateApplicationNameFromExtensionId( 431 web_app::GenerateApplicationNameFromExtensionId(
409 last_loaded_extension_id()), 432 last_loaded_extension_id()),
410 browser()->profile(), 433 browser()->profile(),
411 url, 434 url,
412 nullptr, 435 nullptr,
413 gfx::Rect(300, 400), 436 gfx::Rect(300, 400),
414 PanelManager::CREATE_AS_DOCKED); 437 PanelManager::CREATE_AS_DETACHED);
438 panel->Show();
415 439
416 ASSERT_NO_FATAL_FAILURE( 440 ASSERT_NO_FATAL_FAILURE(
417 WaitForTaskManagerRows(1, MatchExtension("My extension 1"))); 441 WaitForTaskManagerRows(1, MatchExtension("My extension 1")));
418 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows( 442 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(
419 1, 443 1,
420 MatchExtension( 444 MatchExtension(
421 "chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/" 445 "chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/"
422 "french_sentence.html"))); 446 "french_sentence.html")));
423 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyExtension())); 447 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyExtension()));
424 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab())); 448 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab()));
(...skipping 15 matching lines...) Expand all
440 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, KillPanelViaPanelResource) { 464 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, KillPanelViaPanelResource) {
441 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("good") 465 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("good")
442 .AppendASCII("Extensions") 466 .AppendASCII("Extensions")
443 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") 467 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj")
444 .AppendASCII("1.0.0.0"))); 468 .AppendASCII("1.0.0.0")));
445 469
446 // Open a new panel to an extension url. 470 // Open a new panel to an extension url.
447 GURL url( 471 GURL url(
448 "chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/" 472 "chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/"
449 "french_sentence.html"); 473 "french_sentence.html");
450 PanelManager::GetInstance()->CreatePanel( 474 Panel* panel = PanelManager::GetInstance()->CreatePanel(
451 web_app::GenerateApplicationNameFromExtensionId( 475 web_app::GenerateApplicationNameFromExtensionId(
452 last_loaded_extension_id()), 476 last_loaded_extension_id()),
453 browser()->profile(), 477 browser()->profile(),
454 url, 478 url,
455 nullptr, 479 nullptr,
456 gfx::Rect(300, 400), 480 gfx::Rect(300, 400),
457 PanelManager::CREATE_AS_DOCKED); 481 PanelManager::CREATE_AS_DETACHED);
482 panel->ShowInactive();
458 483
459 ShowTaskManager(); 484 ShowTaskManager();
460 ASSERT_NO_FATAL_FAILURE( 485 ASSERT_NO_FATAL_FAILURE(
461 WaitForTaskManagerRows(1, MatchExtension("My extension 1"))); 486 WaitForTaskManagerRows(1, MatchExtension("My extension 1")));
462 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows( 487 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(
463 1, 488 1,
464 MatchExtension( 489 MatchExtension(
465 "chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/" 490 "chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/"
466 "french_sentence.html"))); 491 "french_sentence.html")));
467 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyExtension())); 492 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyExtension()));
468 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab())); 493 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab()));
469 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); 494 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab()));
470 495
471 int background_page = FindResourceIndex(MatchExtension("My extension 1")); 496 int background_page = FindResourceIndex(MatchExtension("My extension 1"));
472 ASSERT_NE(-1, background_page); 497 ASSERT_NE(-1, background_page);
473 ASSERT_EQ(-1, model()->GetTabId(background_page)); 498 ASSERT_EQ(-1, model()->GetTabId(background_page));
474 499
475 // Kill the process via the PANEL RESOURCE (not the background page). Verify 500 // Kill the process via the PANEL RESOURCE (not the background page). Verify
476 // that both the background page and the panel go away from the task manager. 501 // that both the background page and the panel go away from the task manager.
477 int panel = FindResourceIndex(MatchExtension( 502 int panel_index = FindResourceIndex(MatchExtension(
478 "chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/" 503 "chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/"
479 "french_sentence.html")); 504 "french_sentence.html"));
480 ASSERT_NE(-1, panel); 505 ASSERT_NE(-1, panel_index);
481 ASSERT_NE(-1, model()->GetTabId(panel)); 506 ASSERT_NE(-1, model()->GetTabId(panel_index));
482 model()->Kill(panel); 507 model()->Kill(panel_index);
483 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnyExtension())); 508 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnyExtension()));
484 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); 509 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab()));
485 } 510 }
486 511
487 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeExtensionTabChanges) { 512 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeExtensionTabChanges) {
488 ShowTaskManager(); 513 ShowTaskManager();
489 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab())); 514 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab()));
490 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); 515 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab()));
491 516
492 ASSERT_TRUE(LoadExtension( 517 ASSERT_TRUE(LoadExtension(
(...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after
1209 WaitForTaskManagerRows(1, MatchTab("Title Of Awesomeness"))); 1234 WaitForTaskManagerRows(1, MatchTab("Title Of Awesomeness")));
1210 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnySubframe())); 1235 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnySubframe()));
1211 1236
1212 HideTaskManager(); 1237 HideTaskManager();
1213 ShowTaskManager(); 1238 ShowTaskManager();
1214 1239
1215 ASSERT_NO_FATAL_FAILURE( 1240 ASSERT_NO_FATAL_FAILURE(
1216 WaitForTaskManagerRows(1, MatchTab("Title Of Awesomeness"))); 1241 WaitForTaskManagerRows(1, MatchTab("Title Of Awesomeness")));
1217 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnySubframe())); 1242 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnySubframe()));
1218 } 1243 }
OLDNEW
« no previous file with comments | « chrome/browser/task_management/task_management_browsertest_util.cc ('k') | chrome/browser/ui/panels/panel_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698