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.
5 #include "chrome/browser/ui/webui/ntp/new_tab_page_sync_handler.h"
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 "testing/gmock/include/gmock/gmock.h"
23 typedef InProcessBrowserTest NewTabPageSyncHandlerBrowserTest
;
25 class MockNewTabPageSyncHandler
: public NewTabPageSyncHandler
{
27 MOCK_METHOD3(SendSyncMessageToPage
, void(MessageType type
, std::string msg
,
28 std::string linktext
));
30 void SetWaitingForInitialPageLoad(bool waiting
) {
31 waiting_for_initial_page_load_
= waiting
;
35 // TODO(samarth): Delete along with the rest of the NTP4 code.
36 IN_PROC_BROWSER_TEST_F(NewTabPageSyncHandlerBrowserTest
,
37 DISABLED_ChangeSigninAllowedToFalse
) {
38 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL
));
39 content::WebUI
* web_ui
=
40 browser()->tab_strip_model()->GetActiveWebContents()->GetWebUI();
41 MockNewTabPageSyncHandler
* mock_handler
= new MockNewTabPageSyncHandler();
42 mock_handler
->SetWaitingForInitialPageLoad(false);
43 web_ui
->AddMessageHandler(mock_handler
);
44 EXPECT_CALL(*mock_handler
, SendSyncMessageToPage(mock_handler
->HIDE
, _
, _
));
45 browser()->profile()->GetPrefs()->SetBoolean(prefs::kSigninAllowed
, false);