Save errno for logging before potentially overwriting it.
[chromium-blink-merge.git] / content / browser / host_zoom_map_impl_unittest.cc
blobccb04e4d8bd07123d9a8f357aaa2edb288ef664e
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
3 // found in the LICENSE file.
5 #include "content/browser/host_zoom_map_impl.h"
7 #include "base/memory/ref_counted.h"
8 #include "base/message_loop.h"
9 #include "content/public/browser/browser_thread.h"
10 #include "content/public/test/test_browser_thread.h"
11 #include "testing/gtest/include/gtest/gtest.h"
13 namespace content {
15 class HostZoomMapTest : public testing::Test {
16 public:
17 HostZoomMapTest() : ui_thread_(BrowserThread::UI, &message_loop_) {
20 protected:
21 base::MessageLoop message_loop_;
22 TestBrowserThread ui_thread_;
25 TEST_F(HostZoomMapTest, GetSetZoomLevel) {
26 HostZoomMapImpl host_zoom_map;
28 double zoomed = 2.5;
29 host_zoom_map.SetZoomLevelForHost("zoomed.com", zoomed);
31 EXPECT_DOUBLE_EQ(0,
32 host_zoom_map.GetZoomLevelForHostAndScheme("http", "normal.com"));
33 EXPECT_DOUBLE_EQ(zoomed,
34 host_zoom_map.GetZoomLevelForHostAndScheme("http", "zoomed.com"));
37 TEST_F(HostZoomMapTest, GetSetZoomLevelWithScheme) {
38 HostZoomMapImpl host_zoom_map;
40 double zoomed = 2.5;
41 double default_zoom = 1.5;
43 host_zoom_map.SetZoomLevelForHostAndScheme("chrome", "login", 0);
45 host_zoom_map.SetDefaultZoomLevel(default_zoom);
47 EXPECT_DOUBLE_EQ(0,
48 host_zoom_map.GetZoomLevelForHostAndScheme("chrome", "login"));
49 EXPECT_DOUBLE_EQ(default_zoom,
50 host_zoom_map.GetZoomLevelForHostAndScheme("http", "login"));
52 host_zoom_map.SetZoomLevelForHost("login", zoomed);
54 EXPECT_DOUBLE_EQ(0,
55 host_zoom_map.GetZoomLevelForHostAndScheme("chrome", "login"));
56 EXPECT_DOUBLE_EQ(zoomed,
57 host_zoom_map.GetZoomLevelForHostAndScheme("http", "login"));
60 } // namespace content