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

Side by Side Diff: chrome/browser/chromeos/offline/offline_load_page_unittest.cc

Issue 9706012: Add abstractions that let embedders drive tests of WebContents. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove CONTENT_EXPORT on statically linked functions. Merge to head for commit. Created 8 years, 9 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 "chrome/browser/chromeos/cros/cros_library.h" 5 #include "chrome/browser/chromeos/cros/cros_library.h"
6 #include "chrome/browser/chromeos/offline/offline_load_page.h" 6 #include "chrome/browser/chromeos/offline/offline_load_page.h"
7 #include "chrome/test/base/chrome_render_view_host_test_harness.h" 7 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
8 #include "content/browser/tab_contents/test_tab_contents.h"
9 #include "content/public/browser/interstitial_page.h" 8 #include "content/public/browser/interstitial_page.h"
9 #include "content/public/browser/navigation_controller.h"
10 #include "content/public/browser/web_contents.h"
10 #include "content/test/test_browser_thread.h" 11 #include "content/test/test_browser_thread.h"
12 #include "content/test/web_contents_tester.h"
11 13
12 using content::BrowserThread; 14 using content::BrowserThread;
13 using content::InterstitialPage; 15 using content::InterstitialPage;
16 using content::WebContents;
17 using content::WebContentsTester;
14 18
15 static const char* kURL1 = "http://www.google.com/"; 19 static const char* kURL1 = "http://www.google.com/";
16 static const char* kURL2 = "http://www.gmail.com/"; 20 static const char* kURL2 = "http://www.gmail.com/";
17 21
18 namespace chromeos { 22 namespace chromeos {
19 23
20 class OfflineLoadPageTest; 24 class OfflineLoadPageTest;
21 25
22 // An OfflineLoadPage class that does not create windows. 26 // An OfflineLoadPage class that does not create windows.
23 class TestOfflineLoadPage : public chromeos::OfflineLoadPage { 27 class TestOfflineLoadPage : public chromeos::OfflineLoadPage {
24 public: 28 public:
25 TestOfflineLoadPage(TabContents* tab_contents, 29 TestOfflineLoadPage(WebContents* web_contents,
26 const GURL& url, 30 const GURL& url,
27 OfflineLoadPageTest* test_page) 31 OfflineLoadPageTest* test_page)
28 : chromeos::OfflineLoadPage(tab_contents, url, CompletionCallback()), 32 : chromeos::OfflineLoadPage(web_contents, url, CompletionCallback()),
29 test_page_(test_page) { 33 test_page_(test_page) {
30 interstitial_page_->DontCreateViewForTesting(); 34 interstitial_page_->DontCreateViewForTesting();
31 } 35 }
32 36
33 // chromeos::OfflineLoadPage override. 37 // chromeos::OfflineLoadPage override.
34 virtual void NotifyBlockingPageComplete(bool proceed) OVERRIDE; 38 virtual void NotifyBlockingPageComplete(bool proceed) OVERRIDE;
35 39
36 private: 40 private:
37 OfflineLoadPageTest* test_page_; 41 OfflineLoadPageTest* test_page_;
38 42
(...skipping 22 matching lines...) Expand all
61 } 65 }
62 66
63 void OnBlockingPageComplete(bool proceed) { 67 void OnBlockingPageComplete(bool proceed) {
64 if (proceed) 68 if (proceed)
65 user_response_ = OK; 69 user_response_ = OK;
66 else 70 else
67 user_response_ = CANCEL; 71 user_response_ = CANCEL;
68 } 72 }
69 73
70 void Navigate(const char* url, int page_id) { 74 void Navigate(const char* url, int page_id) {
71 contents()->TestDidNavigate( 75 WebContentsTester::For(contents())->TestDidNavigate(
72 contents()->GetRenderViewHost(), page_id, GURL(url), 76 contents()->GetRenderViewHost(), page_id, GURL(url),
73 content::PAGE_TRANSITION_TYPED); 77 content::PAGE_TRANSITION_TYPED);
74 } 78 }
75 79
76 void ShowInterstitial(const char* url) { 80 void ShowInterstitial(const char* url) {
77 (new TestOfflineLoadPage(contents(), GURL(url), this))->Show(); 81 (new TestOfflineLoadPage(contents(), GURL(url), this))->Show();
78 } 82 }
79 83
80 // Returns the OfflineLoadPage currently showing or NULL if none is 84 // Returns the OfflineLoadPage currently showing or NULL if none is
81 // showing. 85 // showing.
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 // The interstitial should be gone. 152 // The interstitial should be gone.
149 EXPECT_EQ(CANCEL, user_response()); 153 EXPECT_EQ(CANCEL, user_response());
150 EXPECT_FALSE(GetOfflineLoadPage()); 154 EXPECT_FALSE(GetOfflineLoadPage());
151 // We did not proceed, the pending entry should be gone. 155 // We did not proceed, the pending entry should be gone.
152 EXPECT_FALSE(controller().GetPendingEntry()); 156 EXPECT_FALSE(controller().GetPendingEntry());
153 // the URL is set back to kURL1. 157 // the URL is set back to kURL1.
154 EXPECT_EQ(kURL1, contents()->GetURL().spec()); 158 EXPECT_EQ(kURL1, contents()->GetURL().spec());
155 } 159 }
156 160
157 } // namespace chromeos 161 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/bookmarks/bookmark_utils.h ('k') | chrome/browser/content_settings/tab_specific_content_settings_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698