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

Side by Side Diff: chrome/browser/instant/instant_browsertest.cc

Issue 11262015: Remove unused / unnecessary stuff from Instant. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove SuggestedTextView entirely Created 8 years, 2 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 (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 "base/stringprintf.h" 5 #include "base/stringprintf.h"
6 #include "chrome/browser/content_settings/host_content_settings_map.h" 6 #include "chrome/browser/content_settings/host_content_settings_map.h"
7 #include "chrome/browser/history/history_service_factory.h" 7 #include "chrome/browser/history/history_service_factory.h"
8 #include "chrome/browser/instant/instant_controller.h" 8 #include "chrome/browser/instant/instant_controller.h"
9 #include "chrome/browser/instant/instant_loader.h" 9 #include "chrome/browser/instant/instant_loader.h"
10 #include "chrome/browser/instant/instant_model.h" 10 #include "chrome/browser/instant/instant_model.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 47
48 // InstantModelObserver overrides: 48 // InstantModelObserver overrides:
49 virtual void DisplayStateChanged(const InstantModel& model) OVERRIDE { 49 virtual void DisplayStateChanged(const InstantModel& model) OVERRIDE {
50 run_loop_.Quit(); 50 run_loop_.Quit();
51 } 51 }
52 52
53 private: 53 private:
54 const InstantModel* const model_; 54 const InstantModel* const model_;
55 base::RunLoop run_loop_; 55 base::RunLoop run_loop_;
56 56
57 DISALLOW_IMPLICIT_CONSTRUCTORS(InstantTestModelObserver); 57 DISALLOW_COPY_AND_ASSIGN(InstantTestModelObserver);
58 }; 58 };
59 59
60 class InstantTest : public InProcessBrowserTest { 60 class InstantTest : public InProcessBrowserTest {
61 protected: 61 protected:
62 void SetupInstant(const std::string& page) { 62 void SetupInstant(const std::string& page) {
63 ASSERT_TRUE(test_server()->Start()); 63 ASSERT_TRUE(test_server()->Start());
64 64
65 TemplateURLService* service = 65 TemplateURLService* service =
66 TemplateURLServiceFactory::GetForProfile(browser()->profile()); 66 TemplateURLServiceFactory::GetForProfile(browser()->profile());
67 ui_test_utils::WaitForTemplateURLServiceToLoad(service); 67 ui_test_utils::WaitForTemplateURLServiceToLoad(service);
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 size_t start = 0, end = 0; 431 size_t start = 0, end = 0;
432 omnibox()->GetSelectionBounds(&start, &end); 432 omnibox()->GetSelectionBounds(&start, &end);
433 if (start > end) 433 if (start > end)
434 std::swap(start, end); 434 std::swap(start, end);
435 435
436 EXPECT_EQ(ASCIIToUTF16("query suggestion"), text); 436 EXPECT_EQ(ASCIIToUTF16("query suggestion"), text);
437 EXPECT_EQ(ASCIIToUTF16(" suggestion"), text.substr(start, end - start)); 437 EXPECT_EQ(ASCIIToUTF16(" suggestion"), text.substr(start, end - start));
438 EXPECT_EQ(ASCIIToUTF16(""), omnibox()->GetInstantSuggestion()); 438 EXPECT_EQ(ASCIIToUTF16(""), omnibox()->GetInstantSuggestion());
439 } 439 }
440 440
441 #if defined(OS_MACOSX)
442 // The "delayed" completion behavior is not implemented on the Mac. Strange.
443 #define MAYBE_SuggestionIsCompletedDelayed DISABLED_SuggestionIsCompletedDelayed
444 #else
445 #define MAYBE_SuggestionIsCompletedDelayed SuggestionIsCompletedDelayed
446 #endif
447 // Test that the INSTANT_COMPLETE_DELAYED behavior works as expected.
448 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE_SuggestionIsCompletedDelayed) {
449 ASSERT_NO_FATAL_FAILURE(SetupInstant("instant.html"));
450 FocusOmniboxAndWaitForInstantSupport();
451
452 // Tell the JS to request the given behavior.
453 EXPECT_TRUE(ExecuteScript("behavior = 'delayed'"));
454
455 // Type a query, causing the hardcoded "query suggestion" to be returned.
456 SetOmniboxTextAndWaitForInstantToShow("query");
457
458 content::WindowedNotificationObserver instant_updated_observer(
459 chrome::NOTIFICATION_INSTANT_CONTROLLER_UPDATED,
460 content::NotificationService::AllSources());
461
462 // Get what's showing in the omnibox, and what's highlighted.
463 string16 text = omnibox()->GetText();
464 size_t start = 0, end = 0;
465 omnibox()->GetSelectionBounds(&start, &end);
466 if (start > end)
467 std::swap(start, end);
468
469 EXPECT_EQ(ASCIIToUTF16("query"), text);
470 EXPECT_EQ(ASCIIToUTF16(""), text.substr(start, end - start));
471 EXPECT_EQ(ASCIIToUTF16(" suggestion"), omnibox()->GetInstantSuggestion());
472
473 // Wait for the animation to complete, which causes the omnibox to update.
474 instant_updated_observer.Wait();
475
476 text = omnibox()->GetText();
477 omnibox()->GetSelectionBounds(&start, &end);
478 if (start > end)
479 std::swap(start, end);
480
481 EXPECT_EQ(ASCIIToUTF16("query suggestion"), text);
482 EXPECT_EQ(ASCIIToUTF16(" suggestion"), text.substr(start, end - start));
483 EXPECT_EQ(ASCIIToUTF16(""), omnibox()->GetInstantSuggestion());
484 }
485
486 // Test that the INSTANT_COMPLETE_NEVER behavior works as expected. 441 // Test that the INSTANT_COMPLETE_NEVER behavior works as expected.
487 IN_PROC_BROWSER_TEST_F(InstantTest, SuggestionIsCompletedNever) { 442 IN_PROC_BROWSER_TEST_F(InstantTest, SuggestionIsCompletedNever) {
488 ASSERT_NO_FATAL_FAILURE(SetupInstant("instant.html")); 443 ASSERT_NO_FATAL_FAILURE(SetupInstant("instant.html"));
489 FocusOmniboxAndWaitForInstantSupport(); 444 FocusOmniboxAndWaitForInstantSupport();
490 445
491 // Tell the JS to request the given behavior. 446 // Tell the JS to request the given behavior.
492 EXPECT_TRUE(ExecuteScript("behavior = 'never'")); 447 EXPECT_TRUE(ExecuteScript("behavior = 'never'"));
493 448
494 // Type a query, causing the hardcoded "query suggestion" to be returned. 449 // Type a query, causing the hardcoded "query suggestion" to be returned.
495 SetOmniboxTextAndWaitForInstantToShow("query"); 450 SetOmniboxTextAndWaitForInstantToShow("query");
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after
965 // Check that a d with a dot above and below it is completed regardless of 920 // Check that a d with a dot above and below it is completed regardless of
966 // how that is encoded. 921 // how that is encoded.
967 // U+1E0D = LATIN SMALL LETTER D WITH DOT BELOW 922 // U+1E0D = LATIN SMALL LETTER D WITH DOT BELOW
968 // U+1E0B = LATIN SMALL LETTER D WITH DOT ABOVE 923 // U+1E0B = LATIN SMALL LETTER D WITH DOT ABOVE
969 EXPECT_TRUE(ExecuteScript("suggestion = [ { value: '\\u1e0d\\u0307oh' } ]")); 924 EXPECT_TRUE(ExecuteScript("suggestion = [ { value: '\\u1e0d\\u0307oh' } ]"));
970 925
971 instant()->Hide(); 926 instant()->Hide();
972 SetOmniboxTextAndWaitForInstantToShow(WideToUTF8(L"\u1e0b\u0323")); 927 SetOmniboxTextAndWaitForInstantToShow(WideToUTF8(L"\u1e0b\u0323"));
973 EXPECT_EQ(WideToUTF16(L"\u1e0b\u0323oh"), omnibox()->GetText()); 928 EXPECT_EQ(WideToUTF16(L"\u1e0b\u0323oh"), omnibox()->GetText());
974 } 929 }
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/search_provider_unittest.cc ('k') | chrome/browser/instant/instant_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698