OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/browser/ui/webui/ntp/new_tab_page_sync_handler.h" | |
6 | |
7 #include "base/prefs/pref_service.h" | |
8 #include "chrome/browser/ui/browser.h" | |
9 #include "chrome/browser/ui/tabs/tab_strip_model.h" | |
10 #include "chrome/common/pref_names.h" | |
11 #include "chrome/common/url_constants.h" | |
12 #include "chrome/test/base/in_process_browser_test.h" | |
13 #include "chrome/test/base/testing_profile.h" | |
14 #include "chrome/test/base/ui_test_utils.h" | |
15 #include "content/public/browser/web_contents.h" | |
16 #include "content/public/browser/web_ui.h" | |
17 #include "content/public/test/browser_test_utils.h" | |
18 #include "googleurl/src/gurl.h" | |
19 #include "testing/gmock/include/gmock/gmock.h" | |
20 | |
21 using ::testing::_; | |
22 | |
23 typedef InProcessBrowserTest NewTabPageSyncHandlerBrowserTest; | |
24 | |
25 class MockNewTabPageSyncHandler : public NewTabPageSyncHandler { | |
26 public: | |
27 MOCK_METHOD3(SendSyncMessageToPage, void(MessageType type, std::string msg, | |
28 std::string linktext)); | |
sail
2013/02/20 23:08:21
new line after this
Adrian Kuegel
2013/02/21 15:48:59
Done.
| |
29 void SetWaitingForInitialPageLoad(bool waiting) { | |
30 waiting_for_initial_page_load_ = waiting; | |
31 } | |
sail
2013/02/20 23:08:21
new line after this
Adrian Kuegel
2013/02/21 15:48:59
Done.
| |
32 MessageType GetHideType() { | |
sail
2013/02/20 23:08:21
Not sure what this is. Can you remove this and har
Adrian Kuegel
2013/02/21 15:48:59
I just added the test class as friend, so I could
| |
33 return HIDE; | |
34 } | |
35 }; | |
36 | |
37 IN_PROC_BROWSER_TEST_F(NewTabPageSyncHandlerBrowserTest, | |
38 ChangeSigninAllowedToFalse) { | |
39 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL)); | |
40 content::WebUI* web_ui = | |
41 browser()->tab_strip_model()->GetActiveWebContents()->GetWebUI(); | |
42 MockNewTabPageSyncHandler* mock_handler = new MockNewTabPageSyncHandler(); | |
43 mock_handler->SetWaitingForInitialPageLoad(false); | |
44 web_ui->AddMessageHandler(mock_handler); | |
45 EXPECT_CALL(*mock_handler, SendSyncMessageToPage( | |
46 mock_handler->GetHideType(), _, _)); | |
47 browser()->profile()->GetPrefs()->SetBoolean(prefs::kSigninAllowed, false); | |
48 } | |
OLD | NEW |