]> git.sur5r.net Git - i3/i3/blobdiff - testcases/t/533-randr15.t
Merge pull request #3614 from NilsIrl/next
[i3/i3] / testcases / t / 533-randr15.t
index da51a097eff88af763569db27591b58c1b282e56..51d1c9f67a034518f100a0fef3f83e9207c14989 100644 (file)
@@ -2,13 +2,13 @@
 # vim:ts=4:sw=4:expandtab
 #
 # Please read the following documents before working on tests:
-# • http://build.i3wm.org/docs/testsuite.html
+# • https://build.i3wm.org/docs/testsuite.html
 #   (or docs/testsuite)
 #
-# • http://build.i3wm.org/docs/lib-i3test.html
+# • https://build.i3wm.org/docs/lib-i3test.html
 #   (alternatively: perldoc ./testcases/lib/i3test.pm)
 #
-# • http://build.i3wm.org/docs/ipc.html
+# • https://build.i3wm.org/docs/ipc.html
 #   (or docs/ipc)
 #
 # • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
 use File::Temp qw(tempfile);
 use i3test i3_autostart => 0;
 
+my $monitor_name = 'i3-fake-monitor';
+my $output_name = 'i3-fake-output';
+
 my $config = <<EOT;
 # i3 config file (v4)
 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
 
+bar {
+    output $output_name
+}
 EOT
 
 my ($outfh, $outname) = tempfile('i3-randr15reply-XXXXXX', UNLINK => 1);
@@ -42,13 +48,13 @@ my $reply = pack('cxSLLLLx[LLL]',
 
 # Manually intern _NET_CURRENT_DESKTOP as $x->atom will not create atoms if
 # they are not yet interned.
-my $atom_cookie = $x->intern_atom(0, length("DP3"), "DP3");
-my $DP3 = $x->intern_atom_reply($atom_cookie->{sequence})->{atom};
+my $atom_cookie = $x->intern_atom(0, length($monitor_name), $monitor_name);
+my $monitor_name_atom = $x->intern_atom_reply($atom_cookie->{sequence})->{atom};
 
 # MONITORINFO is defined in A.1.1 in
 # https://cgit.freedesktop.org/xorg/proto/randrproto/tree/randrproto.txt
 my $monitor1 = pack('LccSssSSLLL',
-        $DP3, # name (ATOM)
+        $monitor_name_atom, # name (ATOM)
         1, # primary
         1, # automatic
         1, # ncrtcs
@@ -67,7 +73,6 @@ close($outfh);
 
 # Prepare a RRGetOutputInfo reply as well; see RRGetOutputInfo in
 # https://www.x.org/releases/current/doc/randrproto/randrproto.txt
-my $output_name = 'i3-fake-output';
 ($outfh, my $outname_moninfo) = tempfile('i3-randr15reply-XXXXXX', UNLINK => 1);
 my $moninfo = pack('cxSLLLx[LLccSSSS]S a* x!4',
                    1, # reply
@@ -89,15 +94,26 @@ my $pid = launch_with_config($config,
 
 my $tree = i3->get_tree->recv;
 my @outputs = map { $_->{name} } @{$tree->{nodes}};
-is_deeply(\@outputs, [ '__i3', 'DP3' ], 'outputs are __i3 and DP3');
+is_deeply(\@outputs, [ '__i3', $monitor_name ], 'outputs are __i3 and the fake monitor');
 
-my ($dp3) = grep { $_->{name} eq 'DP3' } @{$tree->{nodes}};
-is_deeply($dp3->{rect}, {
+my ($output_data) = grep { $_->{name} eq $monitor_name } @{$tree->{nodes}};
+is_deeply($output_data->{rect}, {
         width => 3840,
         height => 2160,
         x => 0,
         y => 0,
-    }, 'Output DP3 at 3840x2160+0+0');
+    }, "Fake output at 3840x2160+0+0");
+
+# Verify that i3 canonicalizes RandR output names to i3 output names
+# (RandR monitor names) for bar configs
+
+my $bars = i3->get_bar_config()->recv;
+is(@$bars, 1, 'one bar configured');
+
+my $bar_id = shift @$bars;
+
+my $bar_config = i3->get_bar_config($bar_id)->recv;
+is_deeply($bar_config->{outputs}, [ $monitor_name ], 'bar_config output name is normalized');
 
 exit_gracefully($pid);
 
@@ -114,10 +130,16 @@ $tree = i3->get_tree->recv;
 is_deeply(\@outputs, [ '__i3', 'default' ], 'outputs are __i3 and default');
 
 SKIP: {
-    skip 'xrandr --setmonitor failed (xrandr too old?)', 1 unless
-        system(q|xrandr --setmonitor up2414q 3840/527x2160/296+1280+0 none|) == 0;
-
-    sync_with_i3;
+    my @events = events_for(
+        sub {
+            skip 'xrandr --setmonitor failed (xrandr too old?)', 1
+              unless system(q|xrandr --setmonitor up2414q 3840/527x2160/296+1280+0 none|) == 0;
+        },
+        "workspace");
+
+    my @init = grep { $_->{change} eq 'init' } @events;
+    is(scalar @init, 1, 'Received 1 workspace::init event');
+    is($init[0]->{current}->{output}, 'up2414q', 'Workspace initialized in up2414q');
 
     $tree = i3->get_tree->recv;
     @outputs = map { $_->{name} } @{$tree->{nodes}};