OLD | NEW |
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 #import <Carbon/Carbon.h> | 5 #import <Carbon/Carbon.h> |
6 #import <Cocoa/Cocoa.h> | 6 #import <Cocoa/Cocoa.h> |
7 #import <Foundation/Foundation.h> | 7 #import <Foundation/Foundation.h> |
8 #import <Foundation/NSAppleEventDescriptor.h> | 8 #import <Foundation/NSAppleEventDescriptor.h> |
9 #import <objc/message.h> | 9 #import <objc/message.h> |
10 #import <objc/runtime.h> | 10 #import <objc/runtime.h> |
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 Method original = class_getInstanceMethod(appControllerClass, | 364 Method original = class_getInstanceMethod(appControllerClass, |
365 targetMethod); | 365 targetMethod); |
366 Method destination = class_getInstanceMethod(openShortcutClass, | 366 Method destination = class_getInstanceMethod(openShortcutClass, |
367 targetMethod); | 367 targetMethod); |
368 | 368 |
369 ASSERT_TRUE(original != NULL); | 369 ASSERT_TRUE(original != NULL); |
370 ASSERT_TRUE(destination != NULL); | 370 ASSERT_TRUE(destination != NULL); |
371 | 371 |
372 method_exchangeImplementations(original, destination); | 372 method_exchangeImplementations(original, destination); |
373 | 373 |
374 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 374 ASSERT_TRUE(embedded_test_server()->Start()); |
375 g_open_shortcut_url = embedded_test_server()->GetURL("/simple.html"); | 375 g_open_shortcut_url = embedded_test_server()->GetURL("/simple.html"); |
376 } | 376 } |
377 | 377 |
378 void SetUpCommandLine(base::CommandLine* command_line) override { | 378 void SetUpCommandLine(base::CommandLine* command_line) override { |
379 // If the arg is empty, PrepareTestCommandLine() after this function will | 379 // If the arg is empty, PrepareTestCommandLine() after this function will |
380 // append about:blank as default url. | 380 // append about:blank as default url. |
381 command_line->AppendArg(chrome::kChromeUINewTabURL); | 381 command_line->AppendArg(chrome::kChromeUINewTabURL); |
382 } | 382 } |
383 }; | 383 }; |
384 | 384 |
385 IN_PROC_BROWSER_TEST_F(AppControllerOpenShortcutBrowserTest, | 385 IN_PROC_BROWSER_TEST_F(AppControllerOpenShortcutBrowserTest, |
386 OpenShortcutOnStartup) { | 386 OpenShortcutOnStartup) { |
387 EXPECT_EQ(1, browser()->tab_strip_model()->count()); | 387 EXPECT_EQ(1, browser()->tab_strip_model()->count()); |
388 EXPECT_EQ(g_open_shortcut_url, | 388 EXPECT_EQ(g_open_shortcut_url, |
389 browser()->tab_strip_model()->GetActiveWebContents() | 389 browser()->tab_strip_model()->GetActiveWebContents() |
390 ->GetLastCommittedURL()); | 390 ->GetLastCommittedURL()); |
391 } | 391 } |
392 | 392 |
393 class AppControllerReplaceNTPBrowserTest : public InProcessBrowserTest { | 393 class AppControllerReplaceNTPBrowserTest : public InProcessBrowserTest { |
394 protected: | 394 protected: |
395 AppControllerReplaceNTPBrowserTest() {} | 395 AppControllerReplaceNTPBrowserTest() {} |
396 | 396 |
397 void SetUpInProcessBrowserTestFixture() override { | 397 void SetUpInProcessBrowserTestFixture() override { |
398 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 398 ASSERT_TRUE(embedded_test_server()->Start()); |
399 } | 399 } |
400 | 400 |
401 void SetUpCommandLine(base::CommandLine* command_line) override { | 401 void SetUpCommandLine(base::CommandLine* command_line) override { |
402 // If the arg is empty, PrepareTestCommandLine() after this function will | 402 // If the arg is empty, PrepareTestCommandLine() after this function will |
403 // append about:blank as default url. | 403 // append about:blank as default url. |
404 command_line->AppendArg(chrome::kChromeUINewTabURL); | 404 command_line->AppendArg(chrome::kChromeUINewTabURL); |
405 } | 405 } |
406 }; | 406 }; |
407 | 407 |
408 // Tests that when a GURL is opened after startup, it replaces the NTP. | 408 // Tests that when a GURL is opened after startup, it replaces the NTP. |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
626 browser->tab_strip_model()->CloseWebContentsAt( | 626 browser->tab_strip_model()->CloseWebContentsAt( |
627 index, TabStripModel::CLOSE_CREATE_HISTORICAL_TAB); | 627 index, TabStripModel::CLOSE_CREATE_HISTORICAL_TAB); |
628 destroyed_watcher.Wait(); | 628 destroyed_watcher.Wait(); |
629 } | 629 } |
630 }; | 630 }; |
631 | 631 |
632 // Tests that as a user switches between tabs, navigates within a tab, and | 632 // Tests that as a user switches between tabs, navigates within a tab, and |
633 // switches between browser windows, the correct URL is being passed to the | 633 // switches between browser windows, the correct URL is being passed to the |
634 // Handoff. | 634 // Handoff. |
635 IN_PROC_BROWSER_TEST_F(AppControllerHandoffBrowserTest, TestHandoffURLs) { | 635 IN_PROC_BROWSER_TEST_F(AppControllerHandoffBrowserTest, TestHandoffURLs) { |
636 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 636 ASSERT_TRUE(embedded_test_server()->Start()); |
637 EXPECT_EQ(g_handoff_url, GURL(url::kAboutBlankURL)); | 637 EXPECT_EQ(g_handoff_url, GURL(url::kAboutBlankURL)); |
638 | 638 |
639 // Test that navigating to a URL updates the handoff URL. | 639 // Test that navigating to a URL updates the handoff URL. |
640 GURL test_url1 = embedded_test_server()->GetURL("/title1.html"); | 640 GURL test_url1 = embedded_test_server()->GetURL("/title1.html"); |
641 ui_test_utils::NavigateToURL(browser(), test_url1); | 641 ui_test_utils::NavigateToURL(browser(), test_url1); |
642 EXPECT_EQ(g_handoff_url, test_url1); | 642 EXPECT_EQ(g_handoff_url, test_url1); |
643 | 643 |
644 // Test that opening a new tab updates the handoff URL. | 644 // Test that opening a new tab updates the handoff URL. |
645 GURL test_url2 = embedded_test_server()->GetURL("/title2.html"); | 645 GURL test_url2 = embedded_test_server()->GetURL("/title2.html"); |
646 chrome::NavigateParams params(browser(), test_url2, ui::PAGE_TRANSITION_LINK); | 646 chrome::NavigateParams params(browser(), test_url2, ui::PAGE_TRANSITION_LINK); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
692 ui_test_utils::NavigateToURL(browser3, test_url1); | 692 ui_test_utils::NavigateToURL(browser3, test_url1); |
693 EXPECT_EQ(g_handoff_url, GURL()); | 693 EXPECT_EQ(g_handoff_url, GURL()); |
694 | 694 |
695 // Activate the original browser window. | 695 // Activate the original browser window. |
696 Browser* browser1 = active_browser_list->get(0); | 696 Browser* browser1 = active_browser_list->get(0); |
697 browser1->window()->Show(); | 697 browser1->window()->Show(); |
698 EXPECT_EQ(g_handoff_url, test_url2); | 698 EXPECT_EQ(g_handoff_url, test_url2); |
699 } | 699 } |
700 | 700 |
701 } // namespace | 701 } // namespace |
OLD | NEW |