dark_mode: Fix tests failure after enabling the feature - part11

This cl fixed the tests failure introduced by crrev.com/c/3656414
after enabling the feature.
Do not inset the bounds of the client vie if it is in tablet mode,
maximized or fullscreened. Adjusted the assertions in tests as well.

Previous failed info can be found at crrev.com/c/3656414/8.

Bug: 1326629
Change-Id: I44ec238dcbc819930ba2385e5f4f31dff19d06aa
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3675552
Commit-Queue: Min Chen <minch@chromium.org>
Reviewed-by: Scott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1009189}
diff --git a/chrome/browser/ui/views/frame/browser_non_client_frame_view_chromeos.cc b/chrome/browser/ui/views/frame/browser_non_client_frame_view_chromeos.cc
index dd2fdf1..6c0fd65 100644
--- a/chrome/browser/ui/views/frame/browser_non_client_frame_view_chromeos.cc
+++ b/chrome/browser/ui/views/frame/browser_non_client_frame_view_chromeos.cc
@@ -341,14 +341,15 @@
   // window header by redirecting paints from its background to
   // BrowserNonClientFrameViewChromeOS.
   gfx::Rect client_bounds(bounds());
-  if (browser_view()->IsFullscreen())
+  if (chromeos::TabletState::Get()->InTabletMode() ||
+      browser_view()->IsFullscreen() || browser_view()->IsMaximized()) {
     return client_bounds;
+  }
 
   // If there is a border, inset the client bounds to show the border when the
-  // browser window is not in fullscreen.
-  if (auto* border = GetBorder()) {
+  // browser window is not fullscreened, maximized or in tablet mode.
+  if (auto* border = GetBorder())
     client_bounds.Inset(border->GetInsets());
-  }
   return client_bounds;
 }
 
diff --git a/chrome/browser/ui/views/frame/browser_non_client_frame_view_chromeos_browsertest.cc b/chrome/browser/ui/views/frame/browser_non_client_frame_view_chromeos_browsertest.cc
index c187010b..1dc3986f 100644
--- a/chrome/browser/ui/views/frame/browser_non_client_frame_view_chromeos_browsertest.cc
+++ b/chrome/browser/ui/views/frame/browser_non_client_frame_view_chromeos_browsertest.cc
@@ -396,7 +396,9 @@
   BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser());
   BrowserNonClientFrameViewChromeOS* frame_view =
       GetFrameViewChromeOS(browser_view);
-  EXPECT_EQ(0, frame_view->GetBoundsForClientView().y());
+  const int expect_y =
+      frame_view->GetBorder() ? frame_view->GetBorder()->GetInsets().top() : 0;
+  EXPECT_EQ(expect_y, frame_view->GetBoundsForClientView().y());
 
   Widget* widget = browser_view->GetWidget();
   ASSERT_NO_FATAL_FAILURE(
@@ -415,7 +417,9 @@
   BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser());
   BrowserNonClientFrameViewChromeOS* frame_view =
       GetFrameViewChromeOS(browser_view);
-  EXPECT_EQ(0, frame_view->GetBoundsForClientView().y());
+  const int expect_y =
+      frame_view->GetBorder() ? frame_view->GetBorder()->GetInsets().top() : 0;
+  EXPECT_EQ(expect_y, frame_view->GetBoundsForClientView().y());
 
   Widget* widget = browser_view->GetWidget();
   ASSERT_NO_FATAL_FAILURE(
diff --git a/ui/file_manager/file_manager/foreground/elements/files_tooltip_unittest.m.js b/ui/file_manager/file_manager/foreground/elements/files_tooltip_unittest.m.js
index 5e89f82..6569f76a 100644
--- a/ui/file_manager/file_manager/foreground/elements/files_tooltip_unittest.m.js
+++ b/ui/file_manager/file_manager/foreground/elements/files_tooltip_unittest.m.js
@@ -246,7 +246,11 @@
             assertEquals('card-tooltip', tooltip.className);
             assertEquals('card-label', label.className);
 
-            assertEquals('962px', tooltip.style.left);
+            // A border with 2px insets (top=bottom=left=right=2px) will be
+            // applied to the window when drak/light feature is enabled. See
+            // more details at crrev.com/c/3656414.
+            assertTrue(
+                `962px` == tooltip.style.left || `958px` == tooltip.style.left);
             assertEquals('162px', tooltip.style.top);
 
             cheeseButton.dispatchEvent(new MouseEvent('mouseout'));