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

Side by Side Diff: chrome/browser/ui/cocoa/browser_window_cocoa_unittest.mm

Issue 1432803002: Removed emojis from generated_resources.grd and update the code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Prevent leaking strings in the unit test Created 5 years 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
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 "base/mac/scoped_nsobject.h" 5 #include "base/mac/scoped_nsobject.h"
6 #include "base/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
7 #include "base/strings/string_util.h" 7 #include "base/strings/string_util.h"
8 #include "chrome/browser/chrome_notification_types.h" 8 #include "chrome/browser/chrome_notification_types.h"
9 #include "chrome/browser/fullscreen.h" 9 #include "chrome/browser/fullscreen.h"
10 #include "chrome/browser/ui/bookmarks/bookmark_utils.h" 10 #include "chrome/browser/ui/bookmarks/bookmark_utils.h"
11 #import "chrome/browser/ui/cocoa/browser_window_cocoa.h" 11 #import "chrome/browser/ui/cocoa/browser_window_cocoa.h"
12 #import "chrome/browser/ui/cocoa/browser_window_controller.h" 12 #import "chrome/browser/ui/cocoa/browser_window_controller.h"
13 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" 13 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h"
14 #include "chrome/grit/generated_resources.h"
14 #include "chrome/test/base/testing_profile.h" 15 #include "chrome/test/base/testing_profile.h"
15 #include "content/public/browser/notification_details.h" 16 #include "content/public/browser/notification_details.h"
16 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
17 #import "third_party/ocmock/OCMock/OCMock.h" 18 #import "third_party/ocmock/OCMock/OCMock.h"
18 #import "third_party/ocmock/gtest_support.h" 19 #import "third_party/ocmock/gtest_support.h"
20 #include "ui/base/l10n/l10n_util_mac.h"
19 21
20 // Main test class. 22 // Main test class.
21 class BrowserWindowCocoaTest : public CocoaProfileTest { 23 class BrowserWindowCocoaTest : public CocoaProfileTest {
22 void SetUp() override { 24 void SetUp() override {
23 CocoaProfileTest::SetUp(); 25 CocoaProfileTest::SetUp();
24 ASSERT_TRUE(browser()); 26 ASSERT_TRUE(browser());
25 27
26 controller_ = [[BrowserWindowController alloc] initWithBrowser:browser() 28 controller_ = [[BrowserWindowController alloc] initWithBrowser:browser()
27 takeOwnership:NO]; 29 takeOwnership:NO];
28 } 30 }
(...skipping 12 matching lines...) Expand all
41 new BrowserWindowCocoa(browser(), controller_)); 43 new BrowserWindowCocoa(browser(), controller_));
42 44
43 bool before = bwc->IsBookmarkBarVisible(); 45 bool before = bwc->IsBookmarkBarVisible();
44 chrome::ToggleBookmarkBarWhenVisible(profile()); 46 chrome::ToggleBookmarkBarWhenVisible(profile());
45 EXPECT_NE(before, bwc->IsBookmarkBarVisible()); 47 EXPECT_NE(before, bwc->IsBookmarkBarVisible());
46 48
47 chrome::ToggleBookmarkBarWhenVisible(profile()); 49 chrome::ToggleBookmarkBarWhenVisible(profile());
48 EXPECT_EQ(before, bwc->IsBookmarkBarVisible()); 50 EXPECT_EQ(before, bwc->IsBookmarkBarVisible());
49 } 51 }
50 52
53 TEST_F(BrowserWindowCocoaTest, TestWindowTitle) {
54 scoped_ptr<BrowserWindowCocoa> bwc(
55 new BrowserWindowCocoa(browser(), controller_));
56 NSString* playing_emoji = @"🔊";
57 NSString* muting_emoji = @"🔇";
58 EXPECT_EQ(static_cast<NSUInteger>(NSNotFound),
59 [bwc->WindowTitle() rangeOfString:playing_emoji].location);
60 EXPECT_EQ(static_cast<NSUInteger>(NSNotFound),
61 [bwc->WindowTitle() rangeOfString:muting_emoji].location);
62 bwc->UpdateMediaState(TAB_MEDIA_STATE_AUDIO_PLAYING);
63 EXPECT_NE(static_cast<NSUInteger>(NSNotFound),
64 [bwc->WindowTitle() rangeOfString:playing_emoji].location);
65 bwc->UpdateMediaState(TAB_MEDIA_STATE_AUDIO_MUTING);
66 EXPECT_NE(static_cast<NSUInteger>(NSNotFound),
67 [bwc->WindowTitle() rangeOfString:muting_emoji].location);
68 bwc->UpdateMediaState(TAB_MEDIA_STATE_NONE);
69 EXPECT_EQ(static_cast<NSUInteger>(NSNotFound),
70 [bwc->WindowTitle() rangeOfString:playing_emoji].location);
71 EXPECT_EQ(static_cast<NSUInteger>(NSNotFound),
72 [bwc->WindowTitle() rangeOfString:muting_emoji].location);
73 }
74
51 // Test that IsMaximized() returns false when the browser window goes from 75 // Test that IsMaximized() returns false when the browser window goes from
52 // maximized to minimized state - http://crbug/452976. 76 // maximized to minimized state - http://crbug/452976.
53 TEST_F(BrowserWindowCocoaTest, TestMinimizeState) { 77 TEST_F(BrowserWindowCocoaTest, TestMinimizeState) {
54 scoped_ptr<BrowserWindowCocoa> bwc( 78 scoped_ptr<BrowserWindowCocoa> bwc(
55 new BrowserWindowCocoa(browser(), controller_)); 79 new BrowserWindowCocoa(browser(), controller_));
56 80
57 EXPECT_FALSE(bwc->IsMinimized()); 81 EXPECT_FALSE(bwc->IsMinimized());
58 bwc->Maximize(); 82 bwc->Maximize();
59 EXPECT_TRUE(bwc->IsMaximized()); 83 EXPECT_TRUE(bwc->IsMaximized());
60 EXPECT_FALSE(bwc->IsMinimized()); 84 EXPECT_FALSE(bwc->IsMinimized());
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 [[[window_ stub] andReturn:nil] delegate]; 202 [[[window_ stub] andReturn:nil] delegate];
179 [[[controller_ stub] andReturn:window_] window]; 203 [[[controller_ stub] andReturn:window_] window];
180 [[window_ expect] orderOut:nil]; 204 [[window_ expect] orderOut:nil];
181 [[window_ expect] close]; 205 [[window_ expect] close];
182 CreateAndCloseBrowserWindow(); 206 CreateAndCloseBrowserWindow();
183 EXPECT_OCMOCK_VERIFY(controller_); 207 EXPECT_OCMOCK_VERIFY(controller_);
184 EXPECT_OCMOCK_VERIFY(window_); 208 EXPECT_OCMOCK_VERIFY(window_);
185 } 209 }
186 210
187 // TODO(???): test other methods of BrowserWindowCocoa 211 // TODO(???): test other methods of BrowserWindowCocoa
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/browser_window_cocoa.mm ('k') | chrome/browser/ui/cocoa/browser_window_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698