Popular sites on the NTP: check that experiment group StartsWith (rather than IS...
[chromium-blink-merge.git] / chrome / browser / ui / cocoa / extensions / media_galleries_dialog_cocoa_browsertest.mm
blob91836303d57b5196a0a69dda15d5eb2e0a4fb0c5
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
3 // found in the LICENSE file.
5 #include "base/strings/utf_string_conversions.h"
6 #include "chrome/browser/ui/cocoa/extensions/media_galleries_dialog_cocoa.h"
8 #include "chrome/browser/media_galleries/media_galleries_dialog_controller_mock.h"
9 #include "chrome/browser/ui/browser.h"
10 #include "chrome/browser/ui/cocoa/constrained_window/constrained_window_alert.h"
11 #include "chrome/browser/ui/tabs/tab_strip_model.h"
12 #include "chrome/test/base/in_process_browser_test.h"
13 #include "components/web_modal/web_contents_modal_dialog_manager.h"
14 #include "content/public/test/test_utils.h"
15 #include "testing/gtest/include/gtest/gtest.h"
17 using ::testing::_;
18 using ::testing::AnyNumber;
19 using ::testing::NiceMock;
20 using ::testing::Return;
21 using ::testing::ReturnRef;
23 class MediaGalleriesDialogBrowserTest : public InProcessBrowserTest {
26 // Verify that programatically closing the constrained window correctly closes
27 // the sheet.
28 IN_PROC_BROWSER_TEST_F(MediaGalleriesDialogBrowserTest, Close) {
29   NiceMock<MediaGalleriesDialogControllerMock> controller;
31   content::WebContents* web_contents =
32       browser()->tab_strip_model()->GetActiveWebContents();
33   EXPECT_CALL(controller, WebContents()).
34       WillRepeatedly(Return(web_contents));
35   std::vector<base::string16> headers;
36   headers.push_back(base::string16());  // The first section has no header.
37   headers.push_back(base::ASCIIToUTF16("header2"));
38   ON_CALL(controller, GetSectionHeaders()).
39       WillByDefault(Return(headers));
40   EXPECT_CALL(controller, GetAuxiliaryButtonText()).
41       WillRepeatedly(Return(base::ASCIIToUTF16("button")));
42   EXPECT_CALL(controller, GetSectionEntries(_)).
43       Times(AnyNumber());
45   scoped_ptr<MediaGalleriesDialogCocoa> dialog(
46       static_cast<MediaGalleriesDialogCocoa*>(
47           MediaGalleriesDialog::Create(&controller)));
48   base::scoped_nsobject<NSWindow> window([[dialog->alert_ window] retain]);
49   EXPECT_TRUE([window isVisible]);
51   web_modal::WebContentsModalDialogManager* manager =
52       web_modal::WebContentsModalDialogManager::FromWebContents(web_contents);
53   web_modal::WebContentsModalDialogManager::TestApi(manager).CloseAllDialogs();
54   EXPECT_FALSE([window isVisible]);