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

Unified Diff: chrome/browser/cocoa/location_bar/location_icon_decoration_unittest.mm

Issue 2958012: [Mac] Bring back the omnibox globe for an encore. (Closed) Base URL: git://codf21.jail/chromium.git
Patch Set: Rohit's suggestions. Created 10 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/cocoa/location_bar/location_icon_decoration.mm ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/cocoa/location_bar/location_icon_decoration_unittest.mm
diff --git a/chrome/browser/cocoa/location_bar/location_icon_decoration_unittest.mm b/chrome/browser/cocoa/location_bar/location_icon_decoration_unittest.mm
new file mode 100644
index 0000000000000000000000000000000000000000..98e1055e298485581a1acd5435592313f1affb5e
--- /dev/null
+++ b/chrome/browser/cocoa/location_bar/location_icon_decoration_unittest.mm
@@ -0,0 +1,59 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#import <Cocoa/Cocoa.h>
+
+#import "chrome/browser/cocoa/location_bar/location_icon_decoration.h"
+
+#import "chrome/browser/cocoa/cocoa_test_helper.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace {
+
+class LocationIconDecorationTest : public CocoaTest {
+ public:
+ LocationIconDecorationTest()
+ : decoration_(NULL) {
+ }
+
+ LocationIconDecoration decoration_;
+};
+
+TEST_F(LocationIconDecorationTest, SetGetImage) {
+ EXPECT_FALSE(decoration_.GetImage());
+
+ const NSSize kImageSize = NSMakeSize(20.0, 20.0);
+ scoped_nsobject<NSImage> image([[NSImage alloc] initWithSize:kImageSize]);
+
+ decoration_.SetImage(image);
+ EXPECT_EQ(decoration_.GetImage(), image);
+
+ decoration_.SetImage(nil);
+ EXPECT_FALSE(decoration_.GetImage());
+}
+
+TEST_F(LocationIconDecorationTest, GetWidthForSpace) {
+ const CGFloat kWide = 100.0;
+ const CGFloat kNarrow = 10.0;
+
+ // Decoration with no image is omitted.
+ EXPECT_EQ(decoration_.GetWidthForSpace(kWide),
+ LocationBarDecoration::kOmittedWidth);
+
+ const NSSize kImageSize = NSMakeSize(20.0, 20.0);
+ scoped_nsobject<NSImage> image([[NSImage alloc] initWithSize:kImageSize]);
+
+ // Decoration takes up the space of the image.
+ decoration_.SetImage(image);
+ EXPECT_EQ(decoration_.GetWidthForSpace(kWide), kImageSize.width);
+
+ // If the image doesn't fit, decoration is omitted.
+ EXPECT_EQ(decoration_.GetWidthForSpace(kNarrow),
+ LocationBarDecoration::kOmittedWidth);
+}
+
+// TODO(shess): It would be nice to test mouse clicks and dragging,
+// but those are hard because they require a real |owner|.
+
+} // namespace
« no previous file with comments | « chrome/browser/cocoa/location_bar/location_icon_decoration.mm ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698