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

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

Issue 7892007: Add ChromeRenderViewHostTestHarness to get rid of the dependency from RVHTH to profile (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix mac Created 9 years, 3 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "content/browser/browser_thread.h" 8 #include "content/browser/browser_thread.h"
8 #include "content/browser/renderer_host/test_render_view_host.h"
9 #include "content/browser/tab_contents/navigation_entry.h" 9 #include "content/browser/tab_contents/navigation_entry.h"
10 #include "content/browser/tab_contents/test_tab_contents.h" 10 #include "content/browser/tab_contents/test_tab_contents.h"
11 #include "content/common/view_messages.h" 11 #include "content/common/view_messages.h"
12 12
13 static const char* kURL1 = "http://www.google.com/"; 13 static const char* kURL1 = "http://www.google.com/";
14 static const char* kURL2 = "http://www.gmail.com/"; 14 static const char* kURL2 = "http://www.gmail.com/";
15 15
16 namespace { 16 namespace {
17 17
18 // An OfflineLoadPage class that does not create windows. 18 // An OfflineLoadPage class that does not create windows.
19 class TestOfflineLoadPage : public chromeos::OfflineLoadPage { 19 class TestOfflineLoadPage : public chromeos::OfflineLoadPage {
20 public: 20 public:
21 TestOfflineLoadPage(TabContents* tab_contents, 21 TestOfflineLoadPage(TabContents* tab_contents,
22 const GURL& url, 22 const GURL& url,
23 Delegate* delegate) 23 Delegate* delegate)
24 : chromeos::OfflineLoadPage(tab_contents, url, delegate) { 24 : chromeos::OfflineLoadPage(tab_contents, url, delegate) {
25 EnableTest(); 25 EnableTest();
26 } 26 }
27 27
28 // Overriden from InterstitialPage. Don't create a view. 28 // Overriden from InterstitialPage. Don't create a view.
29 virtual TabContentsView* CreateTabContentsView() { 29 virtual TabContentsView* CreateTabContentsView() {
30 return NULL; 30 return NULL;
31 } 31 }
32 }; 32 };
33 33
34 } // namespace 34 } // namespace
35 35
36 namespace chromeos { 36 namespace chromeos {
37 37
38 class OfflineLoadPageTest : public RenderViewHostTestHarness, 38 class OfflineLoadPageTest : public ChromeRenderViewHostTestHarness,
39 public OfflineLoadPage::Delegate { 39 public OfflineLoadPage::Delegate {
40 public: 40 public:
41 // The decision the user made. 41 // The decision the user made.
42 enum UserResponse { 42 enum UserResponse {
43 PENDING, 43 PENDING,
44 OK, 44 OK,
45 CANCEL 45 CANCEL
46 }; 46 };
47 47
48 OfflineLoadPageTest() 48 OfflineLoadPageTest()
49 : ui_thread_(BrowserThread::UI, MessageLoop::current()), 49 : ui_thread_(BrowserThread::UI, MessageLoop::current()),
50 io_thread_(BrowserThread::IO, MessageLoop::current()) { 50 io_thread_(BrowserThread::IO, MessageLoop::current()) {
51 } 51 }
52 52
53 virtual void SetUp() { 53 virtual void SetUp() {
54 RenderViewHostTestHarness::SetUp(); 54 ChromeRenderViewHostTestHarness::SetUp();
55 user_response_ = PENDING; 55 user_response_ = PENDING;
56 } 56 }
57 57
58 // OfflineLoadPage::Delegate implementation. 58 // OfflineLoadPage::Delegate implementation.
59 virtual void OnBlockingPageComplete(bool proceed) { 59 virtual void OnBlockingPageComplete(bool proceed) {
60 if (proceed) 60 if (proceed)
61 user_response_ = OK; 61 user_response_ = OK;
62 else 62 else
63 user_response_ = CANCEL; 63 user_response_ = CANCEL;
64 } 64 }
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 // The interstitial should be gone. 138 // The interstitial should be gone.
139 EXPECT_EQ(CANCEL, user_response()); 139 EXPECT_EQ(CANCEL, user_response());
140 EXPECT_FALSE(GetOfflineLoadPage()); 140 EXPECT_FALSE(GetOfflineLoadPage());
141 // We did not proceed, the pending entry should be gone. 141 // We did not proceed, the pending entry should be gone.
142 EXPECT_FALSE(controller().pending_entry()); 142 EXPECT_FALSE(controller().pending_entry());
143 // the URL is set back to kURL1. 143 // the URL is set back to kURL1.
144 EXPECT_EQ(kURL1, contents()->GetURL().spec()); 144 EXPECT_EQ(kURL1, contents()->GetURL().spec());
145 } 145 }
146 146
147 } // namespace chromeos 147 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698