OSDN Git Service

護衛退避時に勝利判定がずれるのを直す
[kancollesniffer/KancolleSniffer.git] / KancolleSniffer.Test / ShipLabelTest.cs
index 355f20e..8283f41 100644 (file)
@@ -53,6 +53,18 @@ namespace KancolleSniffer.Test
             }\r
 \r
             /// <summary>\r
+            /// 文字数制限がない\r
+            /// </summary>\r
+            [TestMethod]\r
+            public void Unlimited()\r
+            {\r
+                var label = new ShipLabel.Name(Point.Empty, ShipNameWidth.Max){Parent = new Panel()};\r
+                var str = "一二三四五六七八九〇一二三四五六七八九〇一二三四五六七八九〇";\r
+                label.SetName(str);\r
+                Assert.AreEqual(str, label.Text);\r
+            }\r
+\r
+            /// <summary>\r
             /// 明石タイマー表示中の艦娘の名前を縮める\r
             /// </summary>\r
             [TestMethod]\r
@@ -212,14 +224,12 @@ namespace KancolleSniffer.Test
                 TestTruncate(data, ShipNameWidth.ShipList);\r
             }\r
 \r
-            private static readonly Font LatinFont = new Font("Tahoma", 8f);\r
-\r
             private static void TestTruncate(TestData data, ShipNameWidth width)\r
             {\r
                 foreach (var zoom in data.Keys)\r
                 {\r
                     SetScaleFactor(zoom);\r
-                    var label = CreateLabel(zoom, width);\r
+                    var label = new ShipLabel.Name(Point.Empty, width) {Font = ShipLabel.Name.BaseFont};\r
                     for (var i = 0; i < data[zoom].Length; i++)\r
                     {\r
                         var entry = data[zoom][i];\r
@@ -231,31 +241,27 @@ namespace KancolleSniffer.Test
                 }\r
             }\r
 \r
-            private static ShipLabel.Name CreateLabel(int zoom, ShipNameWidth width)\r
-            {\r
-                var label = new ShipLabel.Name(Point.Empty, width) {Parent = new Panel()};\r
-                label.Parent.Font = ZoomFont(label.Parent.Font, zoom);\r
-                ShipLabel.Name.LatinFont = ZoomFont(LatinFont, zoom);\r
-                return label;\r
-            }\r
-\r
             private static void SetScaleFactor(int zoom)\r
             {\r
+                var form = new Form {AutoScaleMode = AutoScaleMode.Font};\r
                 if (zoom == 100)\r
                 {\r
                     Scaler.Factor = new SizeF(1, 1);\r
+                    ShipLabel.Name.BaseFont = form.Font;\r
+                    ShipLabel.Name.LatinFont = LatinFont(100);\r
                     return;\r
                 }\r
-                var form = new Form {AutoScaleMode = AutoScaleMode.Font};\r
                 var prev = form.CurrentAutoScaleDimensions;\r
-                form.Font = ZoomFont(form.Font, zoom);\r
+                form.Font = new Font(form.Font.FontFamily, form.Font.Size * zoom / 100);\r
+                ShipLabel.Name.BaseFont = form.Font;\r
+                ShipLabel.Name.LatinFont = LatinFont(zoom);\r
                 var cur = form.CurrentAutoScaleDimensions;\r
                 Scaler.Factor = new SizeF(cur.Width / prev.Width, cur.Height / prev.Height);\r
             }\r
 \r
-            private static Font ZoomFont(Font font, int zoom)\r
+            private static Font LatinFont(int zoom)\r
             {\r
-                return zoom == 100 ? font : new Font(font.FontFamily, font.Size * zoom / 100);\r
+                return new Font("Tahoma", 8f * zoom / 100);\r
             }\r
         }\r
 \r